From 413c29fef72c7ac5f222af71469af2acfada43f9 Mon Sep 17 00:00:00 2001 From: Peter Hutterer Date: Wed, 18 Feb 2015 13:36:44 +1000 Subject: [PATCH 1/3] udev: fix a race condition if a device disappears before we get a handle If the device disappears too quickly, the device is NULL, the sysname is NULL and that causes a segfault in strcmp. Signed-off-by: Peter Hutterer Reviewed-by: Hans de Goede --- src/udev-seat.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/udev-seat.c b/src/udev-seat.c index 3d057336..6615f208 100644 --- a/src/udev-seat.c +++ b/src/udev-seat.c @@ -158,6 +158,8 @@ udev_input_add_devices(struct udev_input *input, struct udev *udev) udev_list_entry_foreach(entry, udev_enumerate_get_list_entry(e)) { path = udev_list_entry_get_name(entry); device = udev_device_new_from_syspath(udev, path); + if (!device) + continue; sysname = udev_device_get_sysname(device); if (strncmp("event", sysname, 5) != 0) { From 002ef1635d3c83c7b5f45ccabe84f9017e862732 Mon Sep 17 00:00:00 2001 From: Peter Hutterer Date: Thu, 19 Feb 2015 11:38:04 +1000 Subject: [PATCH 2/3] cosmetic: drop double empty lines Signed-off-by: Peter Hutterer --- src/evdev.h | 1 - src/libinput-private.h | 1 - src/libinput.c | 1 - src/libinput.h | 2 -- test/device.c | 2 -- tools/event-gui.c | 1 - 6 files changed, 8 deletions(-) diff --git a/src/evdev.h b/src/evdev.h index fc70a287..72082e5a 100644 --- a/src/evdev.h +++ b/src/evdev.h @@ -306,7 +306,6 @@ evdev_post_scroll(struct evdev_device *device, double dx, double dy); - void evdev_stop_scroll(struct evdev_device *device, uint64_t time, diff --git a/src/libinput-private.h b/src/libinput-private.h index 410f39a8..dbe15586 100644 --- a/src/libinput-private.h +++ b/src/libinput-private.h @@ -194,7 +194,6 @@ struct libinput_event_listener { typedef void (*libinput_source_dispatch_t)(void *data); - #define log_debug(li_, ...) log_msg((li_), LIBINPUT_LOG_PRIORITY_DEBUG, __VA_ARGS__) #define log_info(li_, ...) log_msg((li_), LIBINPUT_LOG_PRIORITY_INFO, __VA_ARGS__) #define log_error(li_, ...) log_msg((li_), LIBINPUT_LOG_PRIORITY_ERROR, __VA_ARGS__) diff --git a/src/libinput.c b/src/libinput.c index bb0595e6..c1e68eb1 100644 --- a/src/libinput.c +++ b/src/libinput.c @@ -1603,7 +1603,6 @@ libinput_device_config_send_events_get_default_mode(struct libinput_device *devi return LIBINPUT_CONFIG_SEND_EVENTS_ENABLED; } - LIBINPUT_EXPORT int libinput_device_config_accel_is_available(struct libinput_device *device) { diff --git a/src/libinput.h b/src/libinput.h index 09503a29..56c3ca13 100644 --- a/src/libinput.h +++ b/src/libinput.h @@ -90,7 +90,6 @@ enum libinput_button_state { LIBINPUT_BUTTON_STATE_PRESSED = 1 }; - /** * @ingroup device * @@ -2417,7 +2416,6 @@ libinput_device_config_click_get_method(struct libinput_device *device); enum libinput_config_click_method libinput_device_config_click_get_default_method(struct libinput_device *device); - /** * @ingroup config * diff --git a/test/device.c b/test/device.c index e72ef198..0839bfae 100644 --- a/test/device.c +++ b/test/device.c @@ -189,7 +189,6 @@ START_TEST(device_disable_touchpad) litest_touch_move_to(dev, 0, 50, 50, 90, 90, 10, 0); litest_touch_up(dev, 0); - litest_assert_empty_queue(li); /* no event from resuming */ @@ -519,7 +518,6 @@ START_TEST(device_disable_release_tap_n_drag) } END_TEST - START_TEST(device_disable_release_softbutton) { struct litest_device *dev = litest_current_device(); diff --git a/tools/event-gui.c b/tools/event-gui.c index 70dd8541..85c5ab13 100644 --- a/tools/event-gui.c +++ b/tools/event-gui.c @@ -254,7 +254,6 @@ change_ptraccel(struct window *w, double amount) } } - static void handle_event_device_notify(struct libinput_event *ev) { From ed0f0bf4945a5b396ce9511aa583857af95cb430 Mon Sep 17 00:00:00 2001 From: Peter Hutterer Date: Thu, 19 Feb 2015 07:22:59 +1000 Subject: [PATCH 3/3] test: fix Coverity complaints seat_button_count seat_key_count ... uninitialized variable t = zalloc s = zalloc ... dereferencing potential NULL-pointer d->ntouches_down... side-effect in assertion Coverity run against the 0.10.0 tag, see https://scan.coverity.com/projects/4298 Signed-off-by: Peter Hutterer Reviewed-by: Hans de Goede Reviewed-by: Christian Hartmann --- test/keyboard.c | 2 +- test/litest.c | 9 +++++++-- test/pointer.c | 2 +- 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/test/keyboard.c b/test/keyboard.c index 4563ce6f..cb7ad522 100644 --- a/test/keyboard.c +++ b/test/keyboard.c @@ -36,7 +36,7 @@ START_TEST(keyboard_seat_key_count) struct libinput_event *ev; struct libinput_event_keyboard *kev; int i; - int seat_key_count; + int seat_key_count = 0; int expected_key_button_count = 0; char device_name[255]; diff --git a/test/litest.c b/test/litest.c index b220b2fe..16d92399 100644 --- a/test/litest.c +++ b/test/litest.c @@ -184,6 +184,7 @@ litest_add_tcase_for_device(struct suite *suite, } t = zalloc(sizeof(*t)); + assert(t != NULL); t->name = strdup(test_name); t->tc = tcase_create(test_name); list_insert(&suite->tests, &t->node); @@ -215,6 +216,7 @@ litest_add_tcase_no_device(struct suite *suite, void *func) } t = zalloc(sizeof(*t)); + assert(t != NULL); t->name = strdup(test_name); t->tc = tcase_create(test_name); list_insert(&suite->tests, &t->node); @@ -270,6 +272,7 @@ get_suite(const char *name) } s = zalloc(sizeof(*s)); + assert(s != NULL); s->name = strdup(name); s->suite = suite_create(s->name); @@ -808,7 +811,8 @@ litest_touch_down(struct litest_device *d, unsigned int slot, { struct input_event *ev; - assert(++d->ntouches_down > 0); + assert(d->ntouches_down >= 0); + d->ntouches_down++; send_btntool(d); @@ -836,7 +840,8 @@ litest_touch_up(struct litest_device *d, unsigned int slot) { .type = -1, .code = -1 } }; - assert(--d->ntouches_down >= 0); + assert(d->ntouches_down > 0); + d->ntouches_down--; send_btntool(d); diff --git a/test/pointer.c b/test/pointer.c index 2e52a206..24ea7266 100644 --- a/test/pointer.c +++ b/test/pointer.c @@ -470,7 +470,7 @@ START_TEST(pointer_seat_button_count) struct libinput_event *ev; struct libinput_event_pointer *tev; int i; - int seat_button_count; + int seat_button_count = 0; int expected_seat_button_count = 0; char device_name[255];