[<prev] [next>] [day] [month] [year] [list]
Message-Id: <20191209051523.21772-1-masahiroy@kernel.org>
Date: Mon, 9 Dec 2019 14:15:23 +0900
From: Masahiro Yamada <masahiroy@...nel.org>
To: linux-mtd@...ts.infradead.org
Cc: Masahiro Yamada <yamada.masahiro@...ionext.com>,
Miquel Raynal <miquel.raynal@...tlin.com>,
Richard Weinberger <richard@....at>,
Vignesh Raghavendra <vigneshr@...com>,
linux-kernel@...r.kernel.org
Subject: [PATCH] mtd: rawnand: denali: error out if platform has no associated data
From: Masahiro Yamada <yamada.masahiro@...ionext.com>
denali->ecc_caps is a mandatory parameter. If it were left unset,
nand_ecc_choose_conf() would end up with NULL pointer access.
So, every compatible must be associated with proper denali_dt_data.
If of_device_get_match_data() returns NULL, let it fail immediately.
Signed-off-by: Masahiro Yamada <yamada.masahiro@...ionext.com>
---
drivers/mtd/nand/raw/denali_dt.c | 11 ++++++-----
1 file changed, 6 insertions(+), 5 deletions(-)
diff --git a/drivers/mtd/nand/raw/denali_dt.c b/drivers/mtd/nand/raw/denali_dt.c
index 8b779a899dcf..276187939689 100644
--- a/drivers/mtd/nand/raw/denali_dt.c
+++ b/drivers/mtd/nand/raw/denali_dt.c
@@ -118,11 +118,12 @@ static int denali_dt_probe(struct platform_device *pdev)
denali = &dt->controller;
data = of_device_get_match_data(dev);
- if (data) {
- denali->revision = data->revision;
- denali->caps = data->caps;
- denali->ecc_caps = data->ecc_caps;
- }
+ if (WARN_ON(!data))
+ return -EINVAL;
+
+ denali->revision = data->revision;
+ denali->caps = data->caps;
+ denali->ecc_caps = data->ecc_caps;
denali->dev = dev;
denali->irq = platform_get_irq(pdev, 0);
--
2.17.1
Powered by blists - more mailing lists