[PATCH libevdev 2/2] uinput: preserve the errno before cleaning up

Peter Hutterer peter.hutterer at who-t.net
Mon Aug 11 23:00:32 PDT 2014


libevdev_uinput_destroy() may/will botch the errno, make sure we save it
before use.

Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
---
 libevdev/libevdev-uinput.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/libevdev/libevdev-uinput.c b/libevdev/libevdev-uinput.c
index 4446b45..0cf3054 100644
--- a/libevdev/libevdev-uinput.c
+++ b/libevdev/libevdev-uinput.c
@@ -277,6 +277,7 @@ LIBEVDEV_EXPORT int
 libevdev_uinput_create_from_device(const struct libevdev *dev, int fd, struct libevdev_uinput** uinput_dev)
 {
 	int rc;
+	int errno_preserved;
 	struct uinput_user_dev uidev;
 	struct libevdev_uinput *new_device;
 
@@ -344,8 +345,9 @@ libevdev_uinput_create_from_device(const struct libevdev *dev, int fd, struct li
 	return 0;
 
 error:
+	errno_preserved = errno;
 	libevdev_uinput_destroy(new_device);
-	return -errno;
+	return -errno_preserved;
 }
 
 LIBEVDEV_EXPORT void
-- 
1.9.3



More information about the Input-tools mailing list