From c6478bbeeb6ecc328710f5777e4c4d7596dd6904 Mon Sep 17 00:00:00 2001 From: Peter Hutterer Date: Fri, 22 Aug 2014 14:48:42 +1000 Subject: [PATCH] evdev: plug memory leak on libevdev_new_from_fd failure Found by coverity. Signed-off-by: Peter Hutterer --- src/evdev.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/evdev.c b/src/evdev.c index b9f635db..b09bb989 100644 --- a/src/evdev.c +++ b/src/evdev.c @@ -885,10 +885,11 @@ evdev_device_create(struct libinput_seat *seat, return NULL; libinput_device_init(&device->base, seat); + libinput_seat_ref(seat); rc = libevdev_new_from_fd(fd, &device->evdev); if (rc != 0) - return NULL; + goto err; libevdev_set_clock_id(device->evdev, CLOCK_MONOTONIC); @@ -905,8 +906,6 @@ evdev_device_create(struct libinput_seat *seat, device->pending_event = EVDEV_NONE; device->devname = libevdev_get_name(device->evdev); - libinput_seat_ref(seat); - if (evdev_configure_device(device) == -1) goto err; -- 2.34.1