diff --git a/src/wscons.c b/src/wscons.c index 2120f073..9013c3bd 100644 --- a/src/wscons.c +++ b/src/wscons.c @@ -239,7 +239,7 @@ wscons_device_dispatch(void *data) ssize_t len; int count, i; - len = read(device->fd, wsevents, sizeof(struct wscons_event)); + len = read(device->fd, wsevents, sizeof(wsevents)); if (len <= 0 || (len % sizeof(struct wscons_event)) != 0) return; @@ -576,8 +576,18 @@ libinput_path_add_device(struct libinput *libinput, return device; err: - if (device != NULL) - close_restricted(libinput, device->fd); + if (device != NULL) { + if (device->source) + libinput_remove_source(libinput, device->source); + if (device->devname) { + free(device->devname); + device->devname = NULL; + } + if (device->fd >= 0) + close_restricted(libinput, device->fd); + } else if (fd >= 0) { + close_restricted(libinput, fd); + } free(wscons_device); return NULL; }