diff mbox series

[3/3] mtd: rawnand: tmio: check return value after calling platform_get_resource()

Message ID 20220426084913.4021868-3-yangyingliang@huawei.com (mailing list archive)
State New, archived
Headers show
Series [1/3] mtd: rawnand: cadence: fix possible null-ptr-deref in cadence_nand_dt_probe() | expand

Commit Message

Yang Yingliang April 26, 2022, 8:49 a.m. UTC
It will cause null-ptr-deref if platform_get_resource() returns NULL,
we need check the return value.

Signed-off-by: Yang Yingliang <yangyingliang@huawei.com>
---
 drivers/mtd/nand/raw/tmio_nand.c | 3 +++
 1 file changed, 3 insertions(+)

Comments

Miquel Raynal April 27, 2022, 3:26 p.m. UTC | #1
On Tue, 2022-04-26 at 08:49:13 UTC, Yang Yingliang wrote:
> It will cause null-ptr-deref if platform_get_resource() returns NULL,
> we need check the return value.
> 
> Signed-off-by: Yang Yingliang <yangyingliang@huawei.com>

Applied to https://git.kernel.org/pub/scm/linux/kernel/git/mtd/linux.git nand/next, thanks.

Miquel
diff mbox series

Patch

diff --git a/drivers/mtd/nand/raw/tmio_nand.c b/drivers/mtd/nand/raw/tmio_nand.c
index de8e919d0ebe..8f1a42bf199c 100644
--- a/drivers/mtd/nand/raw/tmio_nand.c
+++ b/drivers/mtd/nand/raw/tmio_nand.c
@@ -390,6 +390,9 @@  static int tmio_probe(struct platform_device *dev)
 	if (data == NULL)
 		dev_warn(&dev->dev, "NULL platform data!\n");
 
+	if (!ccr || !fcr)
+		return -EINVAL;
+
 	tmio = devm_kzalloc(&dev->dev, sizeof(*tmio), GFP_KERNEL);
 	if (!tmio)
 		return -ENOMEM;