summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorkay.sievers@vrfy.org <kay.sievers@vrfy.org>2003-12-17 22:33:29 -0800
committerGreg KH <gregkh@suse.de>2005-04-26 21:13:09 -0700
commita81805b9af899087f3d8367721ac0a51460f692e (patch)
tree31ad2348018b8c9bd796c6f85545459f700f9fdb
parentff3633bf9d192c46c457cc3819dc27ff2807ed0d (diff)
[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)'
-rw-r--r--udev-remove.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/udev-remove.c b/udev-remove.c
index 0886c23343..dad4a98570 100644
--- a/udev-remove.c
+++ b/udev-remove.c
@@ -118,8 +118,8 @@ static int delete_node(struct udevice *dev)
*/
int udev_remove_device(char *path, char *subsystem)
{
- char name[100];
struct udevice *dev;
+ struct udevice device;
char *temp;
dev = udevdb_get_dev(path);
@@ -128,13 +128,15 @@ int udev_remove_device(char *path, char *subsystem)
temp = strrchr(path, '/');
if (temp == NULL)
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);
udevdb_delete_dev(path);
- sysbus_send_remove(name, path);
+ sysbus_send_remove(dev->name, path);
return delete_node(dev);
}