summaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorFabio Estevam <fabio.estevam@nxp.com>2018-01-05 21:02:56 +0100
committerBoris Brezillon <boris.brezillon@free-electrons.com>2018-01-06 10:35:22 +0100
commit039b4377e5621a2cc197a7aff1e06db432e4dcc2 (patch)
tree05b79d5c6ac3f1dca81a30d0e1d63d95b326051a /drivers
parentmtd: nand: Fix unfinished comment in nand_init_data_interface() (diff)
downloadlinux-039b4377e5621a2cc197a7aff1e06db432e4dcc2.tar.xz
linux-039b4377e5621a2cc197a7aff1e06db432e4dcc2.zip
mtd: nand: brcmnand: Add a NULL check for devm_kasprintf()
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>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/mtd/nand/brcmnand/brcmnand.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/drivers/mtd/nand/brcmnand/brcmnand.c b/drivers/mtd/nand/brcmnand/brcmnand.c
index 54842512edb1..e0797abb1ebd 100644
--- a/drivers/mtd/nand/brcmnand/brcmnand.c
+++ b/drivers/mtd/nand/brcmnand/brcmnand.c
@@ -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;