]> git.baikalelectronics.ru Git - kernel.git/commit
mtd: core: Potential NULL dereference in mtd_otp_size()
authorDan Carpenter <dan.carpenter@oracle.com>
Fri, 14 May 2021 14:27:15 +0000 (17:27 +0300)
committerMiquel Raynal <miquel.raynal@bootlin.com>
Wed, 26 May 2021 08:41:43 +0000 (10:41 +0200)
commitdb15b78b4ec44dc377529a8744403f2f10bb4a34
tree7368d2077ca6acf1befa4f70a0c40b6bb74a8834
parent721f1bf35713f4c8692a8563f2c1e14e28bac9d9
mtd: core: Potential NULL dereference in mtd_otp_size()

If kmalloc() fails then it could lead to a NULL dereference.  Check and
return -ENOMEM on error.

Fixes: 489af5af168e ("mtd: core: add OTP nvmem provider support")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Reviewed-by: Michael Walle <michael@walle.cc>
Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Link: https://lore.kernel.org/linux-mtd/YJ6Iw3iNvGycAWV6@mwanda
drivers/mtd/mtdcore.c