mirror of
https://gitlab.freedesktop.org/libevdev/libevdev.git
synced 2025-12-20 22:00:07 +01:00
libevdev_uinput_destroy: don't close non-open FD
The returned errno from libevdev_input_create_from_device was returned
incorrectly because libevdev_uinput_destroy() would try to close the
unset value of ->fd, overwriting errno.
That was fixed in debe9b030c, this patch avoids
the ioctl/close calls if the fd isn't set.
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
This commit is contained in:
parent
f4cc76d96f
commit
867a237c55
1 changed files with 5 additions and 3 deletions
|
|
@ -358,9 +358,11 @@ libevdev_uinput_destroy(struct libevdev_uinput *uinput_dev)
|
||||||
if (!uinput_dev)
|
if (!uinput_dev)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
(void)ioctl(uinput_dev->fd, UI_DEV_DESTROY, NULL);
|
if (uinput_dev->fd >= 0) {
|
||||||
if (uinput_dev->fd_is_managed)
|
(void)ioctl(uinput_dev->fd, UI_DEV_DESTROY, NULL);
|
||||||
close(uinput_dev->fd);
|
if (uinput_dev->fd_is_managed)
|
||||||
|
close(uinput_dev->fd);
|
||||||
|
}
|
||||||
free(uinput_dev->syspath);
|
free(uinput_dev->syspath);
|
||||||
free(uinput_dev->devnode);
|
free(uinput_dev->devnode);
|
||||||
free(uinput_dev->name);
|
free(uinput_dev->name);
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue