connection: don't oops if CANCEL_FD doesn't support poll
authorDavid Herrmann <dh.herrmann@gmail.com>
Fri, 19 Dec 2014 18:41:53 +0000 (19:41 +0100)
committerDavid Herrmann <dh.herrmann@gmail.com>
Fri, 19 Dec 2014 18:50:34 +0000 (19:50 +0100)
Verify the passed CANCEL_FD does actually support ->poll(). Otherwise, we
will call a NULL pointer.

Signed-off-by: David Herrmann <dh.herrmann@gmail.com>
connection.c

index de4a864dbdcd1382cdb93035eb044d1467b9b517..688d1ba122929de91e1c95b669766b08eb39a017 100644 (file)
@@ -651,6 +651,10 @@ static int kdbus_conn_wait_reply(struct kdbus_conn *conn_src,
                cancel_fd = fget(cancel_fd_item->fds[0]);
                if (IS_ERR(cancel_fd))
                        return PTR_ERR(cancel_fd);
+               if (!cancel_fd->f_op->poll) {
+                       fput(cancel_fd);
+                       return -EINVAL;
+               }
 
                cancel_fd->f_op->poll(cancel_fd, &pwq.pt);
        }