Skip to content

Commit 0339f62

Browse files
ZhaoLong Wangmiquelraynal
authored andcommitted
mtd: Add WARN_ON_ONCE() to mtd_read() to check the return value
If the driver cannot read all the requested data, -EBADMSG or -EUCLEAN should never be returned. Add a WARN_ON_ONCE() to help driver developers detect this error. Signed-off-by: ZhaoLong Wang <[email protected]> Signed-off-by: Miquel Raynal <[email protected]> Link: https://lore.kernel.org/linux-mtd/[email protected]
1 parent 3cff177 commit 0339f62

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

drivers/mtd/mtdcore.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1505,6 +1505,8 @@ int mtd_read(struct mtd_info *mtd, loff_t from, size_t len, size_t *retlen,
15051505
ret = mtd_read_oob(mtd, from, &ops);
15061506
*retlen = ops.retlen;
15071507

1508+
WARN_ON_ONCE(*retlen != len && mtd_is_bitflip_or_eccerr(ret));
1509+
15081510
return ret;
15091511
}
15101512
EXPORT_SYMBOL_GPL(mtd_read);

0 commit comments

Comments
 (0)