linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/1] mtd: ubi: fix improper return value
@ 2016-12-04  6:12 Pan Bian
  2016-12-04 12:48 ` Marek Vasut
  0 siblings, 1 reply; 8+ messages in thread
From: Pan Bian @ 2016-12-04  6:12 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

From: Pan Bian <bianpan2016@163.com>

When __vmalloc() returns a NULL pointer, the region is not checked, and
we cannot make sure that only 0xFF bytes are present at offset. Thus,
returning 0 seems improper.

Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=189081

Signed-off-by: Pan Bian <bianpan2016@163.com>
---
 drivers/mtd/ubi/io.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/mtd/ubi/io.c b/drivers/mtd/ubi/io.c
index b6fb8f9..b54fe05 100644
--- a/drivers/mtd/ubi/io.c
+++ b/drivers/mtd/ubi/io.c
@@ -1413,7 +1413,7 @@ int ubi_self_check_all_ff(struct ubi_device *ubi, int pnum, int offset, int len)
 	buf = __vmalloc(len, GFP_NOFS, PAGE_KERNEL);
 	if (!buf) {
 		ubi_err(ubi, "cannot allocate memory to check for 0xFFs");
-		return 0;
+		return -ENOMEM;
 	}
 
 	err = mtd_read(ubi->mtd, addr, len, &read, buf);
-- 
1.9.1

^ permalink raw reply related	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2016-12-05  9:50 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-12-04  6:12 [PATCH 1/1] mtd: ubi: fix improper return value Pan Bian
2016-12-04 12:48 ` Marek Vasut
2016-12-04 20:33   ` Joe Perches
2016-12-04 20:52     ` Richard Weinberger
2016-12-05  7:09       ` Artem Bityutskiy
2016-12-05  8:23         ` Boris Brezillon
2016-12-05  9:49           ` Artem Bityutskiy
2016-12-04 21:36     ` Marek Vasut

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