evdev: plug memory leak on libevdev_new_from_fd failure
authorPeter Hutterer <peter.hutterer@who-t.net>
Fri, 22 Aug 2014 04:48:42 +0000 (14:48 +1000)
committerPeter Hutterer <peter.hutterer@who-t.net>
Tue, 26 Aug 2014 01:04:42 +0000 (11:04 +1000)
Found by coverity.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
src/evdev.c

index b9f635dbdfee785c63dd85bb332f5f4c2610c32e..b09bb989f4187a0ebaa48e38093f1417cb1c9cc9 100644 (file)
@@ -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;