Skip to contentSkip to conversation

fix valgrind error for /sys/kernel/uids/*

PATCH In review Alan Jenkins 2 participants 2 messages Oct 17, 2008

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 fix valgrind error for /sys/kernel/uids/*

Quoted 23 lines · Kay Sievers
Quoted 7 lines · Kay Sievers
Quoted 5 lines · Alan Jenkins

commit 8753fadf2a6ecead372e71b8bf9336cf29f9c958

Lots of the udev tests fail here. udev_sysfs.c broke when util_resolve_sys_link() switched API.

Quoted 9 lines

Ah, sorry, should be fixed now.

Quoted 3 lines

I'll leave this up to you - maybe
your next commit is going to do away with udev_sysfs.c altogether :-).

It will go away soon, yeah. We should get rid of udev_sysfs.c and "struct udevice".

Along with a lot of other stuff, udev_sysfs.c is gone. Also the global event environment is replaced by a per-device property list. The daemon, and everything else uses the libudev code now.

Quoted 7 lines

It seems to work fine here, but the code may be a bit rough at the moment, until it has seen more testing. But, it should be pretty easy now to play around with a threaded version of the daemon.

Thanks,
Kay

# valgrind -q ./udevd &
# udevtrigger
=16329= Invalid read of size 1
=16329=    at 0x40C9DA: udev_device_set_syspath (libudev-device.c:939)
=16329=    by 0x40DFB6: udev_monitor_receive_device
(libudev-monitor.c:318)
=16329=    by 0x411F52: main (udevd.c:889)
=16329=  Address 0x60f2507 is 1 bytes before a block of size 6 alloc'd
=16329=    at 0x4C22FAB: malloc (vg_replace_malloc.c:207)
=16329=    by 0x4EA1DD1: strdup (strdup.c:43)
=16329=    by 0x40C987: udev_device_set_syspath (libudev-device.c:926)
=16329=    by 0x40DFB6: udev_monitor_receive_device
(libudev-monitor.c:318)
=16329=    by 0x411F52: main (udevd.c:889)

The syspath in question was /sys/kernel/uids/65534. Try this?

udev/lib/libudev-device.c +6 -1
index 65ba6e3..dd08439 100644
@@ -936,8 +936,13 @@ int udev_device_set_syspath(struct udev_device *udev_device, const char *syspath
 	}
 
 	/* trailing number */
-	while (isdigit(udev_device->sysname[--len]))
+	while (len > 0 && isdigit(udev_device->sysname[--len]))
 		udev_device->sysnum = &udev_device->sysname[len];
+
+	/* oops, sysname is completely numeric */
+	if (len = 0)
+		udev_device->sysnum = NULL;
+
 	return 0;
 }
 
#1 lore raw
Quoted 20 lines · Alan Jenkins
Quoted 3 lines · Kay Sievers

It seems to work fine here, but the code may be a bit rough at the moment, until it has seen more testing. But, it should be pretty easy now to play around with a threaded version of the daemon.

# valgrind -q ./udevd &
# udevtrigger
=16329= Invalid read of size 1
=16329=    at 0x40C9DA: udev_device_set_syspath (libudev-device.c:939)
=16329=    by 0x40DFB6: udev_monitor_receive_device
(libudev-monitor.c:318)
=16329=    by 0x411F52: main (udevd.c:889)
=16329=  Address 0x60f2507 is 1 bytes before a block of size 6 alloc'd
=16329=    at 0x4C22FAB: malloc (vg_replace_malloc.c:207)
=16329=    by 0x4EA1DD1: strdup (strdup.c:43)
=16329=    by 0x40C987: udev_device_set_syspath (libudev-device.c:926)
=16329=    by 0x40DFB6: udev_monitor_receive_device
(libudev-monitor.c:318)
=16329=    by 0x411F52: main (udevd.c:889)
Quoted 1 line

The syspath in question was /sys/kernel/uids/65534.

Ah, nice. Thanks, applied.

Kay