mtd: nand: brcmnand: Add a NULL check for devm_kasprintf()
authorFabio Estevam <fabio.estevam@nxp.com>
Fri, 5 Jan 2018 20:02:56 +0000 (18:02 -0200)
committerBoris Brezillon <boris.brezillon@free-electrons.com>
Sat, 6 Jan 2018 09:35:22 +0000 (10:35 +0100)
devm_kasprintf() may fail, so we should better add a NULL check
and propagate an error on failure.

Signed-off-by: Fabio Estevam <fabio.estevam@nxp.com>
Signed-off-by: Boris Brezillon <boris.brezillon@free-electrons.com>
drivers/mtd/nand/brcmnand/brcmnand.c

index 54842512edb10f1ca5beaeea8788576c58f3c632..e0797abb1ebd054541845e9356474682f1c123b5 100644 (file)
@@ -2237,6 +2237,9 @@ static int brcmnand_init_cs(struct brcmnand_host *host, struct device_node *dn)
        nand_set_controller_data(chip, host);
        mtd->name = devm_kasprintf(&pdev->dev, GFP_KERNEL, "brcmnand.%d",
                                   host->cs);
+       if (!mtd->name)
+               return -ENOMEM;
+
        mtd->owner = THIS_MODULE;
        mtd->dev.parent = &pdev->dev;