From: Fabio Estevam Date: Fri, 5 Jan 2018 20:02:55 +0000 (-0200) Subject: mtd: nand: qcom: Add a NULL check for devm_kasprintf() X-Git-Tag: v4.14.63~93 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=2424869e4cd1d2d08b0c23b709b116d48d1a42aa;p=platform%2Fkernel%2Flinux-rpi.git mtd: nand: qcom: Add a NULL check for devm_kasprintf() 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 Signed-off-by: Boris Brezillon Signed-off-by: Amit Pundir Signed-off-by: Greg Kroah-Hartman --- diff --git a/drivers/mtd/nand/qcom_nandc.c b/drivers/mtd/nand/qcom_nandc.c index 3baddfc..b49ca02 100644 --- a/drivers/mtd/nand/qcom_nandc.c +++ b/drivers/mtd/nand/qcom_nandc.c @@ -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;