libinput: Fix the close_restricted interface callback
authorJasper St. Pierre <jstpierre@mecheye.net>
Sat, 1 Mar 2014 19:19:03 +0000 (14:19 -0500)
committerPeter Hutterer <peter.hutterer@who-t.net>
Tue, 4 Mar 2014 05:21:38 +0000 (15:21 +1000)
libinput is supposed to take a close callback in its interface
to allow you to call out to a privileged API to close FDs. But
the FD that libinput passes you is bogus, because
libinput_remove_source closes the FD on which it's passed. This
is really bad, as the libinput_source really doesn't own the FD
which it's passed, so it shouldn't be trying to close() it.

Only one out of the four users of libinput_remove_source actually
wants their FD closed, so move the close() call there.

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

index 8185bf27bc8bc899ef4f72329965caa9befcd4d2..65c5ea05e2708b64e0c5b46984d6fd4e13f16533 100644 (file)
@@ -714,6 +714,7 @@ touchpad_destroy(struct evdev_dispatch *dispatch)
        struct libinput *libinput = touchpad->device->base.seat->libinput;
 
        touchpad->filter->interface->destroy(touchpad->filter);
+       close(touchpad->fsm.timer.fd);
        libinput_remove_source(libinput, touchpad->fsm.timer.source);
        free(touchpad->fsm.events);
        free(dispatch);
index 58b87b0f8274319ec4f69f5cd44d35e5c3f335d3..182c401e2b022f8ffc0846db34a2149c242a8dd3 100644 (file)
@@ -442,7 +442,6 @@ libinput_remove_source(struct libinput *libinput,
                       struct libinput_source *source)
 {
        epoll_ctl(libinput->epoll_fd, EPOLL_CTL_DEL, source->fd, NULL);
-       close(source->fd);
        source->fd = -1;
        list_insert(&libinput->source_destroy_list, &source->link);
 }