linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 2/2] mtd: ubi: fix improper return value
@ 2016-12-05  3:19 Pan Bian
  0 siblings, 0 replies; only message in thread
From: Pan Bian @ 2016-12-05  3:19 UTC (permalink / raw)
  To: Artem Bityutskiy, Richard Weinberger, David Woodhouse,
	Brian Norris, Boris Brezillon, Marek Vasut, Cyrille Pitchen,
	linux-mtd
  Cc: linux-kernel, Pan Bian

When __vmalloc() returns a NULL pointer, the data is not really tested,
and we cannot conclude that the data matches. Thus, returning 0 seems
improper. This patch 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 00d7f44..6707277 100644
--- a/drivers/mtd/ubi/io.c
+++ b/drivers/mtd/ubi/io.c
@@ -1347,10 +1347,8 @@ static int self_check_write(struct ubi_device *ubi, const void *buf, int pnum,
 		return 0;
 
 	buf1 = __vmalloc(len, GFP_NOFS, PAGE_KERNEL);
-	if (!buf1) {
-		ubi_err(ubi, "cannot allocate memory to check writes");
-		return 0;
-	}
+	if (!buf1)
+		return -ENOMEM;
 
 	err = mtd_read(ubi->mtd, addr, len, &read, buf1);
 	if (err && !mtd_is_bitflip(err))
-- 
1.9.1

^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2016-12-05  3:21 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-12-05  3:19 [PATCH 2/2] mtd: ubi: fix improper return value Pan Bian

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).