summaryrefslogtreecommitdiffstats
path: root/drivers/mtd/mtdcore.c
diff options
context:
space:
mode:
authorZhaoLong Wang <wangzhaolong1@huawei.com>2023-09-26 14:57:33 +0800
committerMiquel Raynal <miquel.raynal@bootlin.com>2023-10-16 10:50:28 +0200
commit0339f62a9a778bb7cd4f764cd4640cc89155177e (patch)
treec97c521eeced18bbbc59ffc313b3b115157fa577 /drivers/mtd/mtdcore.c
parent3cff177fc2793a362d784c912f536e69a755925e (diff)
downloadlinux-stable-0339f62a9a778bb7cd4f764cd4640cc89155177e.tar.gz
linux-stable-0339f62a9a778bb7cd4f764cd4640cc89155177e.tar.bz2
linux-stable-0339f62a9a778bb7cd4f764cd4640cc89155177e.zip
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
Diffstat (limited to 'drivers/mtd/mtdcore.c')
-rw-r--r--drivers/mtd/mtdcore.c2
1 files changed, 2 insertions, 0 deletions
diff --git a/drivers/mtd/mtdcore.c b/drivers/mtd/mtdcore.c
index 9bd661be3ae9..848ca4ae058d 100644
--- a/drivers/mtd/mtdcore.c
+++ b/drivers/mtd/mtdcore.c
@@ -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);