From: Djalal Harouni Date: Mon, 20 Oct 2014 20:40:35 +0000 (+0100) Subject: message: document the verify fd and increment usage count logic X-Git-Tag: upstream/0.20141102.012929utc~67 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=83f791cbcf08c70713078c80020554c21c031e91;p=platform%2Fcore%2Fsystem%2Fkdbus-bus.git 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 --- 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;