message: document the verify fd and increment usage count logic
authorDjalal Harouni <tixxdz@opendz.org>
Mon, 20 Oct 2014 20:40:35 +0000 (21:40 +0100)
committerDjalal Harouni <tixxdz@opendz.org>
Mon, 20 Oct 2014 20:40:35 +0000 (21:40 +0100)
We explicitly verify the fd and then just increment the usage counter.

Signed-off-by: Djalal Harouni <tixxdz@opendz.org>
message.c

index 2c576264437784444db250d3f698c0111ca8e208..9881801af742363717b8bb1b0498b874e4a585a6 100644 (file)
--- 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;