mdev: revert last wrong commit

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
This commit is contained in:
Denys Vlasenko 2009-05-04 21:59:05 +02:00
parent 6245202e7f
commit 76f5e38c82

View File

@ -101,8 +101,12 @@ static char *build_alias(char *alias, const char *device_name)
return alias; return alias;
} }
/* mknod in /dev based on a path like "/sys/block/hda/hda1" */ /* mknod in /dev based on a path like "/sys/block/hda/hda1"
/* NB: "mdev -s" may call us many times, do not leak memory/fds! */ * NB1: path parameter needs to have SCRATCH_SIZE scratch bytes
* after NUL, but we promise to not mangle (IOW: to restore if needed)
* path string.
* NB2: "mdev -s" may call us many times, do not leak memory/fds!
*/
static void make_device(char *path, int delete) static void make_device(char *path, int delete)
{ {
char *device_name; char *device_name;
@ -565,10 +569,7 @@ int mdev_main(int argc UNUSED_PARAM, char **argv)
make_device(temp, 1); make_device(temp, 1);
} }
else if (strcmp(action, "add") == 0) { else if (strcmp(action, "add") == 0) {
/* make_device mangles its parameter, use a copy */ make_device(temp, 0);
char *s = xstrdup(temp);
make_device(s, 0);
free(s);
if (ENABLE_FEATURE_MDEV_LOAD_FIRMWARE) { if (ENABLE_FEATURE_MDEV_LOAD_FIRMWARE) {
if (fw) if (fw)
load_firmware(fw, temp); load_firmware(fw, temp);