From: Sylwester Nawrocki Date: Tue, 18 May 2021 12:56:13 +0000 (+0200) Subject: kdbus: Remove unreachable code from kdbus_msg_examine X-Git-Tag: submit/tizen/20210531.013858^0 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=d892d39588934e2372651128484509d5279fffce;p=platform%2Fkernel%2Flinux-rpi3.git kdbus: Remove unreachable code from kdbus_msg_examine 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: Ic154b2dbb0740f9e49b68ef273f19cd89e90c200 Signed-off-by: Sylwester Nawrocki --- diff --git a/ipc/kdbus/message.c b/ipc/kdbus/message.c index 17475a652d5c..406d57cba486 100644 --- a/ipc/kdbus/message.c +++ b/ipc/kdbus/message.c @@ -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(VERIFY_READ, ptr, size))) return -EFAULT;