pad: don't clobber the errno if the pad led failed to initialize
authorPeter Hutterer <peter.hutterer@who-t.net>
Thu, 24 Oct 2024 04:47:38 +0000 (14:47 +1000)
committerPeter Hutterer <peter.hutterer@who-t.net>
Thu, 31 Oct 2024 00:28:08 +0000 (10:28 +1000)
pad_led_destroy() may call something that sets errno, so let's protect
against that.

Part-of: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/1070>

src/evdev-tablet-pad-leds.c

index bcb41644c49f0ad175e7ac964f88e43ea14fc2ce..9037d20d20dbd0332f0e05d65200a7ecaea89ea4 100644 (file)
@@ -104,7 +104,7 @@ pad_led_new(struct libinput *libinput, const char *prefix, int group, int mode)
 {
        struct pad_mode_led *led;
        char path[PATH_MAX];
-       int rc, fd;
+       int rc, fd, save_errno;
 
        led = zalloc(sizeof *led);
        led->brightness_fd = -1;
@@ -133,7 +133,9 @@ pad_led_new(struct libinput *libinput, const char *prefix, int group, int mode)
        return led;
 
 error:
+       save_errno = errno;
        pad_led_destroy(libinput, led);
+       errno = save_errno;
        return NULL;
 }
 #endif /* HAVE_LIBWACOM */