Elements of `fds' array were set to -1 in case if we couldn't allocate
a fd. Verify that element contains a valid fd number before submitting
it to put_unused_fd().

Signed-off-by: Sergei Zviagintsev <ser...@s15v.net>
---
 ipc/kdbus/message.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/ipc/kdbus/message.c b/ipc/kdbus/message.c
index 0653a085c104..da685049d66c 100644
--- a/ipc/kdbus/message.c
+++ b/ipc/kdbus/message.c
@@ -221,7 +221,8 @@ int kdbus_gaps_install(struct kdbus_gaps *gaps, struct 
kdbus_pool_slice *slice,
 exit:
        if (ret < 0)
                for (i = 0; i < n_fds; ++i)
-                       put_unused_fd(fds[i]);
+                       if (fds[i] >= 0)
+                               put_unused_fd(fds[i]);
        kfree(fds);
        *out_incomplete = incomplete_fds;
        return ret;
-- 
1.8.3.1

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Reply via email to