All of lore.kernel.org
 help / color / mirror / Atom feed
From: Yang Yingliang <yangyingliang@huawei.com>
To: <linux-kernel@vger.kernel.org>, <linux-mtd@lists.infradead.org>,
	<linux-media@vger.kernel.org>, <dri-devel@lists.freedesktop.org>,
	<linaro-mm-sig@lists.linaro.org>
Cc: richard@nod.at, miquel.raynal@bootlin.com
Subject: [PATCH 3/3] mtd: rawnand: tmio: check return value after calling platform_get_resource()
Date: Tue, 26 Apr 2022 16:49:13 +0800	[thread overview]
Message-ID: <20220426084913.4021868-3-yangyingliang@huawei.com> (raw)
In-Reply-To: <20220426084913.4021868-1-yangyingliang@huawei.com>

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(+)

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;
-- 
2.25.1


WARNING: multiple messages have this Message-ID (diff)
From: Yang Yingliang <yangyingliang@huawei.com>
To: <linux-kernel@vger.kernel.org>, <linux-mtd@lists.infradead.org>,
	<linux-media@vger.kernel.org>, <dri-devel@lists.freedesktop.org>,
	<linaro-mm-sig@lists.linaro.org>
Cc: <miquel.raynal@bootlin.com>, <richard@nod.at>
Subject: [PATCH 3/3] mtd: rawnand: tmio: check return value after calling platform_get_resource()
Date: Tue, 26 Apr 2022 16:49:13 +0800	[thread overview]
Message-ID: <20220426084913.4021868-3-yangyingliang@huawei.com> (raw)
In-Reply-To: <20220426084913.4021868-1-yangyingliang@huawei.com>

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(+)

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;
-- 
2.25.1


______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/

WARNING: multiple messages have this Message-ID (diff)
From: Yang Yingliang <yangyingliang@huawei.com>
To: <linux-kernel@vger.kernel.org>, <linux-mtd@lists.infradead.org>,
	<linux-media@vger.kernel.org>, <dri-devel@lists.freedesktop.org>,
	<linaro-mm-sig@lists.linaro.org>
Cc: <miquel.raynal@bootlin.com>, <richard@nod.at>
Subject: [PATCH 3/3] mtd: rawnand: tmio: check return value after calling platform_get_resource()
Date: Tue, 26 Apr 2022 16:49:13 +0800	[thread overview]
Message-ID: <20220426084913.4021868-3-yangyingliang@huawei.com> (raw)
In-Reply-To: <20220426084913.4021868-1-yangyingliang@huawei.com>

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(+)

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;
-- 
2.25.1


  parent reply	other threads:[~2022-04-26  8:37 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-04-26  8:49 [PATCH 1/3] mtd: rawnand: cadence: fix possible null-ptr-deref in cadence_nand_dt_probe() Yang Yingliang
2022-04-26  8:49 ` Yang Yingliang
2022-04-26  8:49 ` Yang Yingliang
2022-04-26  8:49 ` [PATCH 2/3] mtd: rawnand: intel: fix possible null-ptr-deref in ebu_nand_probe() Yang Yingliang
2022-04-26  8:49   ` Yang Yingliang
2022-04-26  8:49   ` Yang Yingliang
2022-04-27 15:26   ` Miquel Raynal
2022-04-27 15:26     ` Miquel Raynal
2022-04-27 15:26     ` Miquel Raynal
2022-04-26  8:49 ` Yang Yingliang [this message]
2022-04-26  8:49   ` [PATCH 3/3] mtd: rawnand: tmio: check return value after calling platform_get_resource() Yang Yingliang
2022-04-26  8:49   ` Yang Yingliang
2022-04-27 15:26   ` Miquel Raynal
2022-04-27 15:26     ` Miquel Raynal
2022-04-27 15:26     ` Miquel Raynal
2022-04-27 15:26 ` [PATCH 1/3] mtd: rawnand: cadence: fix possible null-ptr-deref in cadence_nand_dt_probe() Miquel Raynal
2022-04-27 15:26   ` Miquel Raynal
2022-04-27 15:26   ` Miquel Raynal

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220426084913.4021868-3-yangyingliang@huawei.com \
    --to=yangyingliang@huawei.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=linaro-mm-sig@lists.linaro.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-media@vger.kernel.org \
    --cc=linux-mtd@lists.infradead.org \
    --cc=miquel.raynal@bootlin.com \
    --cc=richard@nod.at \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.