lkml.org 
[lkml]   [2016]   [Dec]   [4]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH 1/1] mtd: ubi: fix improper return value
Date
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

\
 
 \ /
  Last update: 2016-12-04 07:16    [W:0.059 / U:3.904 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site