[PATCH] bug in udev-remove.c
Uups, we have a bug in udev-remove.c. udev segfaults with NULL-pointer, if the device is not in the database: ./test.block: line 29: 4844 Segmentation fault $BIN block Dec 17 22:47:42 pim udev[4882]: udev_remove_device: '/block/sdy' not found in database, falling back on default name Dec 17 22:47:42 pim udev[4882]: udev_remove_device: name is '(null)'
This commit is contained in:
parent
ff3633bf9d
commit
a81805b9af
|
@ -118,8 +118,8 @@ static int delete_node(struct udevice *dev)
|
||||||
*/
|
*/
|
||||||
int udev_remove_device(char *path, char *subsystem)
|
int udev_remove_device(char *path, char *subsystem)
|
||||||
{
|
{
|
||||||
char name[100];
|
|
||||||
struct udevice *dev;
|
struct udevice *dev;
|
||||||
|
struct udevice device;
|
||||||
char *temp;
|
char *temp;
|
||||||
|
|
||||||
dev = udevdb_get_dev(path);
|
dev = udevdb_get_dev(path);
|
||||||
|
@ -128,13 +128,15 @@ int udev_remove_device(char *path, char *subsystem)
|
||||||
temp = strrchr(path, '/');
|
temp = strrchr(path, '/');
|
||||||
if (temp == NULL)
|
if (temp == NULL)
|
||||||
return -ENODEV;
|
return -ENODEV;
|
||||||
strncpy(name, &temp[1], sizeof(name));
|
memset(&device, 0, sizeof(device));
|
||||||
|
dev = &device;
|
||||||
|
strncpy(device.name, &temp[1], sizeof(device.name));
|
||||||
}
|
}
|
||||||
|
|
||||||
dbg("name is '%s'", dev->name);
|
dbg("name is '%s'", dev->name);
|
||||||
udevdb_delete_dev(path);
|
udevdb_delete_dev(path);
|
||||||
|
|
||||||
sysbus_send_remove(name, path);
|
sysbus_send_remove(dev->name, path);
|
||||||
|
|
||||||
return delete_node(dev);
|
return delete_node(dev);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue