[PATCH 1/2 v2] mtd: ubi: fix improper return value
Pan Bian
bianpan2016 at 163.com
Sun Dec 4 19:19:18 PST 2016
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 at 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
More information about the linux-mtd
mailing list