kdbus: Remove unreachable code from kdbus_msg_examine 65/258665/1 accepted/tizen/unified/20210602.122622 submit/tizen/20210531.013858
authorSylwester Nawrocki <s.nawrocki@samsung.com>
Tue, 18 May 2021 12:56:13 +0000 (14:56 +0200)
committerSylwester Nawrocki <s.nawrocki@samsung.com>
Fri, 21 May 2021 15:59:57 +0000 (17:59 +0200)
This fixes an issue pointed out with SVACE warning:

* UNREACHABLE_CODE: This statement in the source code might be unreachable
  during program execution.
    [unreachable] unreachable at linux-rpi3/ipc/kdbus/message.c:346
    [vec_size > vec_size + size (0 > ANY) is always false] vec_size >
     vec_size + size (0 > ANY) is always false at linux-rpi3/ipc/kdbus/message.c:345

Change-Id: Ia5204bbaad863f88c470e198a081fe58ffb4f208
Signed-off-by: Sylwester Nawrocki <s.nawrocki@samsung.com>
ipc/kdbus/message.c

index 63626c8..d069c52 100644 (file)
@@ -284,7 +284,7 @@ static int kdbus_msg_examine(struct kdbus_msg *msg, struct kdbus_bus *bus,
                             size_t *out_n_fds, size_t *out_n_parts)
 {
        struct kdbus_item *item, *fds = NULL, *bloom = NULL, *dstname = NULL;
-       u64 n_parts, n_memfds, n_fds, vec_size;
+       u64 n_parts, n_memfds, n_fds;
 
        /*
         * Step 1:
@@ -334,7 +334,6 @@ static int kdbus_msg_examine(struct kdbus_msg *msg, struct kdbus_bus *bus,
        n_parts = 0;
        n_memfds = 0;
        n_fds = 0;
-       vec_size = 0;
 
        KDBUS_ITEMS_FOREACH(item, msg->items, KDBUS_ITEMS_SIZE(msg, items)) {
                switch (item->type) {
@@ -342,9 +341,7 @@ static int kdbus_msg_examine(struct kdbus_msg *msg, struct kdbus_bus *bus,
                        void __force __user *ptr = KDBUS_PTR(item->vec.address);
                        u64 size = item->vec.size;
 
-                       if (vec_size + size < vec_size)
-                               return -EMSGSIZE;
-                       if (vec_size + size > KDBUS_MSG_MAX_PAYLOAD_VEC_SIZE)
+                       if (size > KDBUS_MSG_MAX_PAYLOAD_VEC_SIZE)
                                return -EMSGSIZE;
                        if (ptr && unlikely(!access_ok(ptr, size)))
                                return -EFAULT;