From: Peter Hutterer Date: Fri, 22 Aug 2014 04:54:06 +0000 (+1000) Subject: Don't close the fd if libinput_add_fd() fails X-Git-Tag: 0.6.0~23 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=0b26f2592cbe28f35b96a5422fda4bc6298930cb;p=platform%2Fupstream%2Flibinput.git Don't close the fd if libinput_add_fd() fails Let the caller decide what to do with the fd. In the current code the caller can't know if the fd was closed on error since we return NULL on malloc failure as well as on epoll_ctl() failure. In the latter case the fd was closed, not in the former. The caller had to close the fd anyway (and all three callers do), so drop closing the fd from this function. Found by Coverity. Signed-off-by: Peter Hutterer --- diff --git a/src/libinput.c b/src/libinput.c index 90b6a137..ed5eba17 100644 --- a/src/libinput.c +++ b/src/libinput.c @@ -457,7 +457,6 @@ libinput_add_fd(struct libinput *libinput, ep.data.ptr = source; if (epoll_ctl(libinput->epoll_fd, EPOLL_CTL_ADD, fd, &ep) < 0) { - close(source->fd); free(source); return NULL; }