From: Pan Bian <bianpan2016@163.com>
To: Artem Bityutskiy <dedekind1@gmail.com>,
Richard Weinberger <richard@nod.at>,
David Woodhouse <dwmw2@infradead.org>,
Brian Norris <computersforpeace@gmail.com>,
Boris Brezillon <boris.brezillon@free-electrons.com>,
Marek Vasut <marek.vasut@gmail.com>,
Cyrille Pitchen <cyrille.pitchen@atmel.com>,
linux-mtd@lists.infradead.org
Cc: linux-kernel@vger.kernel.org, Pan Bian <bianpan2016@163.com>
Subject: [PATCH 1/2 v2] mtd: ubi: fix improper return value
Date: Mon, 5 Dec 2016 11:19:18 +0800 [thread overview]
Message-ID: <1480907958-19229-1-git-send-email-bianpan2016@163.com> (raw)
When __vmalloc() returns a NULL pointer, the region is not really
checked, and we cannot conclude that only 0xFF bytes are present at
offset. Thus, returing 0 seems improper. This patches fixes it, returns
"-ENOMEM" and removes the warning.
Signed-off-by: Pan Bian <bianpan2016@163.com>
---
drivers/mtd/ubi/io.c | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)
diff --git a/drivers/mtd/ubi/io.c b/drivers/mtd/ubi/io.c
index b6fb8f9..00d7f44 100644
--- a/drivers/mtd/ubi/io.c
+++ b/drivers/mtd/ubi/io.c
@@ -1411,10 +1411,8 @@ int ubi_self_check_all_ff(struct ubi_device *ubi, int pnum, int offset, int len)
return 0;
buf = __vmalloc(len, GFP_NOFS, PAGE_KERNEL);
- if (!buf) {
- ubi_err(ubi, "cannot allocate memory to check for 0xFFs");
- return 0;
- }
+ if (!buf)
+ return -ENOMEM;
err = mtd_read(ubi->mtd, addr, len, &read, buf);
if (err && !mtd_is_bitflip(err)) {
--
1.9.1
reply other threads:[~2016-12-05 3:21 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=1480907958-19229-1-git-send-email-bianpan2016@163.com \
--to=bianpan2016@163.com \
--cc=boris.brezillon@free-electrons.com \
--cc=computersforpeace@gmail.com \
--cc=cyrille.pitchen@atmel.com \
--cc=dedekind1@gmail.com \
--cc=dwmw2@infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mtd@lists.infradead.org \
--cc=marek.vasut@gmail.com \
--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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).