From 83f791cbcf08c70713078c80020554c21c031e91 Mon Sep 17 00:00:00 2001 From: Djalal Harouni Date: Mon, 20 Oct 2014 21:40:35 +0100 Subject: [PATCH] message: document the verify fd and increment usage count logic We explicitly verify the fd and then just increment the usage counter. Signed-off-by: Djalal Harouni --- message.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/message.c b/message.c index 2c57626..9881801 100644 --- a/message.c +++ b/message.c @@ -112,6 +112,9 @@ static int kdbus_handle_check_file(struct file *file) * @kmsg: Message * * Return: 0 on success, negative errno on failure. + * + * On errors, the caller should drop any taken reference with + * kdbus_kmsg_free() */ static int kdbus_msg_scan_items(struct kdbus_conn *conn, struct kdbus_kmsg *kmsg) @@ -174,6 +177,10 @@ static int kdbus_msg_scan_items(struct kdbus_conn *conn, int seals, mask; int fd = item->memfd.fd; + /* + * Verify the fd and increment the usage + * count + */ if (fd < 0 || !(f = fget(fd))) return -EBADF; @@ -229,6 +236,10 @@ static int kdbus_msg_scan_items(struct kdbus_conn *conn, int ret; int fd = item->fds[i]; + /* + * Verify the fd and increment the + * usage count + */ if (fd < 0 || !(f = fget(fd))) return -EBADF; -- 2.34.1