mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2025-01-10 15:10:38 +00:00
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 <wangzhaolong1@huawei.com> Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com> Link: https://lore.kernel.org/linux-mtd/20230926065733.3240322-1-wangzhaolong1@huawei.com
This commit is contained in:
parent
3cff177fc2
commit
0339f62a9a
@ -1505,6 +1505,8 @@ int mtd_read(struct mtd_info *mtd, loff_t from, size_t len, size_t *retlen,
|
||||
ret = mtd_read_oob(mtd, from, &ops);
|
||||
*retlen = ops.retlen;
|
||||
|
||||
WARN_ON_ONCE(*retlen != len && mtd_is_bitflip_or_eccerr(ret));
|
||||
|
||||
return ret;
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(mtd_read);
|
||||
|
Loading…
x
Reference in New Issue
Block a user