linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2] mtd: rawnand: intel: check the mtd name only after setting the variable
@ 2021-01-06 14:09 Martin Blumenstingl
  2021-01-14 15:47 ` Miquel Raynal
  0 siblings, 1 reply; 2+ messages in thread
From: Martin Blumenstingl @ 2021-01-06 14:09 UTC (permalink / raw)
  To: vadivel.muruganx.ramuthevar, linux-mtd, miquel.raynal
  Cc: richard, vigneshr, linux-kernel, Martin Blumenstingl

Move the check for mtd->name after the mtd variable has actually been
initialized.

While here, also drop the NULL assignment to the mtd variable as it's
overwritten later on anyways and the NULL value is never read.

Fixes: 0b1039f016e8a3 ("mtd: rawnand: Add NAND controller support on Intel LGM SoC")
Signed-off-by: Martin Blumenstingl <martin.blumenstingl@googlemail.com>
---
changes since v1:
- don't drop the check but actually move it after the mtd variable has
  been initialized as suggested by Miquel Raynal


 drivers/mtd/nand/raw/intel-nand-controller.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/mtd/nand/raw/intel-nand-controller.c b/drivers/mtd/nand/raw/intel-nand-controller.c
index fdb112e8a90d..a304fda5d1fa 100644
--- a/drivers/mtd/nand/raw/intel-nand-controller.c
+++ b/drivers/mtd/nand/raw/intel-nand-controller.c
@@ -579,7 +579,7 @@ static int ebu_nand_probe(struct platform_device *pdev)
 	struct device *dev = &pdev->dev;
 	struct ebu_nand_controller *ebu_host;
 	struct nand_chip *nand;
-	struct mtd_info *mtd = NULL;
+	struct mtd_info *mtd;
 	struct resource *res;
 	char *resname;
 	int ret;
@@ -647,12 +647,13 @@ static int ebu_nand_probe(struct platform_device *pdev)
 	       ebu_host->ebu + EBU_ADDR_SEL(cs));
 
 	nand_set_flash_node(&ebu_host->chip, dev->of_node);
+
+	mtd = nand_to_mtd(&ebu_host->chip);
 	if (!mtd->name) {
 		dev_err(ebu_host->dev, "NAND label property is mandatory\n");
 		return -EINVAL;
 	}
 
-	mtd = nand_to_mtd(&ebu_host->chip);
 	mtd->dev.parent = dev;
 	ebu_host->dev = dev;
 
-- 
2.30.0


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH v2] mtd: rawnand: intel: check the mtd name only after setting the variable
  2021-01-06 14:09 [PATCH v2] mtd: rawnand: intel: check the mtd name only after setting the variable Martin Blumenstingl
@ 2021-01-14 15:47 ` Miquel Raynal
  0 siblings, 0 replies; 2+ messages in thread
From: Miquel Raynal @ 2021-01-14 15:47 UTC (permalink / raw)
  To: Martin Blumenstingl, vadivel.muruganx.ramuthevar, linux-mtd,
	miquel.raynal
  Cc: richard, vigneshr, linux-kernel

On Wed, 2021-01-06 at 14:09:43 UTC, Martin Blumenstingl wrote:
> Move the check for mtd->name after the mtd variable has actually been
> initialized.
> 
> While here, also drop the NULL assignment to the mtd variable as it's
> overwritten later on anyways and the NULL value is never read.
> 
> Fixes: 0b1039f016e8a3 ("mtd: rawnand: Add NAND controller support on Intel LGM SoC")
> Signed-off-by: Martin Blumenstingl <martin.blumenstingl@googlemail.com>

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

Miquel

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2021-01-14 15:48 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-01-06 14:09 [PATCH v2] mtd: rawnand: intel: check the mtd name only after setting the variable Martin Blumenstingl
2021-01-14 15:47 ` Miquel Raynal

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).