Skip to content

Commit

Permalink
path: don't leak the udev device on failure
Browse files Browse the repository at this point in the history
If by sheer coincidence the device succeeds on the last try, we'd have a
leaking udev device.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
  • Loading branch information
whot committed Nov 7, 2018
1 parent 67b2e32 commit 5685980
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions src/path-seat.c
Original file line number Diff line number Diff line change
Expand Up @@ -308,16 +308,15 @@ udev_device_from_devnode(struct libinput *libinput,

while (dev && !udev_device_get_is_initialized(dev)) {
udev_device_unref(dev);
msleep(10);
dev = udev_device_new_from_devnum(udev, 'c', st.st_rdev);

count++;
if (count > 200) {
log_bug_libinput(libinput,
"udev device never initialized (%s)\n",
devnode);
return NULL;
}
msleep(10);
dev = udev_device_new_from_devnum(udev, 'c', st.st_rdev);
}

return dev;
Expand Down

0 comments on commit 5685980

Please sign in to comment.