[PATCH libinput] udev: fix a race condition if a device disappears before we get a handle

Peter Hutterer peter.hutterer at who-t.net
Tue Feb 17 19:36:44 PST 2015


If the device disappears too quickly, the device is NULL, the sysname is NULL
and that causes a segfault in strcmp.

Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
---
 src/udev-seat.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/src/udev-seat.c b/src/udev-seat.c
index 3d05733..6615f20 100644
--- a/src/udev-seat.c
+++ b/src/udev-seat.c
@@ -158,6 +158,8 @@ udev_input_add_devices(struct udev_input *input, struct udev *udev)
 	udev_list_entry_foreach(entry, udev_enumerate_get_list_entry(e)) {
 		path = udev_list_entry_get_name(entry);
 		device = udev_device_new_from_syspath(udev, path);
+		if (!device)
+			continue;
 
 		sysname = udev_device_get_sysname(device);
 		if (strncmp("event", sysname, 5) != 0) {
-- 
2.1.0



More information about the wayland-devel mailing list