mtd: nand: qcom: Add a NULL check for devm_kasprintf()
authorFabio Estevam <fabio.estevam@nxp.com>
Fri, 5 Jan 2018 20:02:55 +0000 (18:02 -0200)
committerBoris Brezillon <boris.brezillon@free-electrons.com>
Sat, 6 Jan 2018 20:55:42 +0000 (21:55 +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/qcom_nandc.c

index 245d0f39e0aab99e2b322654d80002c4d324479e..6be555806ecaa87eac5d921bf1defa76bd607eca 100644 (file)
@@ -2639,6 +2639,9 @@ static int qcom_nand_host_init(struct qcom_nand_controller *nandc,
 
        nand_set_flash_node(chip, dn);
        mtd->name = devm_kasprintf(dev, GFP_KERNEL, "qcom_nand.%d", host->cs);
+       if (!mtd->name)
+               return -ENOMEM;
+
        mtd->owner = THIS_MODULE;
        mtd->dev.parent = dev;