diff options
| author | Owen W. Taylor <otaylor@fishsoup.net> | 2015-01-19 16:45:49 -0500 |
|---|---|---|
| committer | Peter Hutterer <peter.hutterer@who-t.net> | 2015-01-21 08:48:50 +1000 |
| commit | 867a237c5597ab14daff50253d5d73bcc8a44ef6 (patch) | |
| tree | 2ea26e76874ee9189da5535dd0b06d7b95b6e4d8 | |
| parent | f4cc76d96f411b1ab1a2809379839f5573236f79 (diff) | |
| download | libevdev-867a237c5597ab14daff50253d5d73bcc8a44ef6.tar.gz | |
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 debe9b030c8069cdf78307888ef3b65830b25122, this patch avoids
the ioctl/close calls if the fd isn't set.
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
| -rw-r--r-- | libevdev/libevdev-uinput.c | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/libevdev/libevdev-uinput.c b/libevdev/libevdev-uinput.c index 33b5317..d115b53 100644 --- a/libevdev/libevdev-uinput.c +++ b/libevdev/libevdev-uinput.c @@ -358,9 +358,11 @@ libevdev_uinput_destroy(struct libevdev_uinput *uinput_dev) if (!uinput_dev) return; - (void)ioctl(uinput_dev->fd, UI_DEV_DESTROY, NULL); - if (uinput_dev->fd_is_managed) - close(uinput_dev->fd); + if (uinput_dev->fd >= 0) { + (void)ioctl(uinput_dev->fd, UI_DEV_DESTROY, NULL); + if (uinput_dev->fd_is_managed) + close(uinput_dev->fd); + } free(uinput_dev->syspath); free(uinput_dev->devnode); free(uinput_dev->name); |
