diff mbox series

[for-4.14.y,1/5] mtd: nand: qcom: Add a NULL check for devm_kasprintf()

Message ID 1533042142-8681-1-git-send-email-amit.pundir@linaro.org
State New
Headers show
Series [for-4.14.y,1/5] mtd: nand: qcom: Add a NULL check for devm_kasprintf() | expand

Commit Message

Amit Pundir July 31, 2018, 1:02 p.m. UTC
From: Fabio Estevam <fabio.estevam@nxp.com>


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>

---
Cherry-picked from lede tree https://git.lede-project.org/?p=source.git
Please apply it on 4.9.y as well. Not applicable for 4.4.y and 3.18.y

 drivers/mtd/nand/qcom_nandc.c | 3 +++
 1 file changed, 3 insertions(+)

-- 
2.7.4
diff mbox series

Patch

diff --git a/drivers/mtd/nand/qcom_nandc.c b/drivers/mtd/nand/qcom_nandc.c
index 3baddfc997d1..b49ca02b399d 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;