pad: don't clobber the errno if the pad led failed to initialize

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>
This commit is contained in:
Peter Hutterer 2024-10-24 14:47:38 +10:00
parent 181c667266
commit 7ae4fabb76

View 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 */