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)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 15 Aug 2018 16:12:48 +0000 (18:12 +0200)
commit 069f05346d01e7298939f16533953cdf52370be3 upstream.

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>
Signed-off-by: Amit Pundir <amit.pundir@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/mtd/nand/qcom_nandc.c

index 3baddfc997d139358ec63ff50f6d66c474e48ad9..b49ca02b399da0f4f2391185eab48081f5f03bd3 100644 (file)
@@ -2544,6 +2544,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;