Skip to content

Commit

Permalink
mtd: rawnand: intel: check the mtd name only after setting the variable
Browse files Browse the repository at this point in the history
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: 0b1039f ("mtd: rawnand: Add NAND controller support on Intel LGM SoC")
Signed-off-by: Martin Blumenstingl <martin.blumenstingl@googlemail.com>
Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Link: https://lore.kernel.org/linux-mtd/20210106140943.98072-1-martin.blumenstingl@googlemail.com
  • Loading branch information
Martin Blumenstingl authored and Miquel Raynal committed Jan 14, 2021
1 parent 3c97be6 commit 18f6261
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions drivers/mtd/nand/raw/intel-nand-controller.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;

Expand Down

0 comments on commit 18f6261

Please sign in to comment.