From: Wang Fangpeng <wangfangpeng1@huawei.com>
To: <linux-mtd@lists.infradead.org>, <richard@nod.at>, <dedekind1@gmail.com>
Subject: Coverity Scan:dead code on ubi
Date: Wed, 17 Aug 2016 11:34:51 +0800 [thread overview]
Message-ID: <57B3DB5B.3040406@huawei.com> (raw)
[-- Attachment #1: Type: text/plain, Size: 1218 bytes --]
Hi, folks,
Coverity Scan reports dead code on Linux/drivers/mtd/ubi/io.c:956-957 (kernel-4.7)
945 if (data_size == 0) {
946 ubi_err(ubi, "zero data_size");
947 goto bad;
948 }
949 if (lnum < used_ebs - 1) {
950 if (data_size != usable_leb_size) {
951 ubi_err(ubi, "bad data_size");
952 goto bad;
953 }
954 } else if (lnum == used_ebs - 1) {
955 if (data_size == 0) {
956 ubi_err(ubi, "bad data_size at last LEB");
957 goto bad;
958 }
959 } else {
960 ubi_err(ubi, "too high lnum");
961 goto bad;
962 }
The data_size argument has been checked(data_size == 0) at line 945 and goto bad if true.
At line 955, check it again. but the value of "data_size" must be at least 1, cannot be
equal to 0. So, execution cannot reach line 956-957. it is dead code.
Can we fix this situation by the attach patch?
[-- Attachment #2: 0001-fix-dead-code-at-drivers-mtd-ubi-io.c.patch --]
[-- Type: text/plain, Size: 812 bytes --]
From 0ad250e4be4a1bd446ec527e201aadc613254141 Mon Sep 17 00:00:00 2001
From: wangfagnpeng <wangfangpeng1@huawei.com>
Date: Wed, 17 Aug 2016 11:36:55 +0800
Subject: [PATCH] fix dead code at drivers/mtd/ubi/io.c
---
drivers/mtd/ubi/io.c | 7 +------
1 files changed, 1 insertions(+), 6 deletions(-)
diff --git a/drivers/mtd/ubi/io.c b/drivers/mtd/ubi/io.c
index bf79def..5d6c416 100644
--- a/drivers/mtd/ubi/io.c
+++ b/drivers/mtd/ubi/io.c
@@ -951,12 +951,7 @@ static int validate_vid_hdr(const struct ubi_device *ubi,
ubi_err("bad data_size");
goto bad;
}
- } else if (lnum == used_ebs - 1) {
- if (data_size == 0) {
- ubi_err("bad data_size at last LEB");
- goto bad;
- }
- } else {
+ } else if (lnum > used_ebs - 1) {
ubi_err("too high lnum");
goto bad;
}
--
1.7.7
reply other threads:[~2016-08-17 3:36 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=57B3DB5B.3040406@huawei.com \
--to=wangfangpeng1@huawei.com \
--cc=dedekind1@gmail.com \
--cc=linux-mtd@lists.infradead.org \
--cc=richard@nod.at \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.