[PATCH 2/2] mtd: brcmnand: Add a NULL check for devm_kasprintf()

Boris Brezillon boris.brezillon at free-electrons.com
Sat Jan 6 01:35:57 PST 2018


Hi Fabio,

The prefix should be "mtd: nand: brcmnand: ".

No need to resend, I'll fix it when applying.

Thanks,

Boris

On Fri,  5 Jan 2018 18:02:56 -0200
Fabio Estevam <festevam at gmail.com> wrote:

> From: Fabio Estevam <fabio.estevam at nxp.com>
> 
> 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 at nxp.com>
> ---
>  drivers/mtd/nand/brcmnand/brcmnand.c | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/drivers/mtd/nand/brcmnand/brcmnand.c b/drivers/mtd/nand/brcmnand/brcmnand.c
> index 3310e14..8942aa6 100644
> --- a/drivers/mtd/nand/brcmnand/brcmnand.c
> +++ b/drivers/mtd/nand/brcmnand/brcmnand.c
> @@ -2237,6 +2237,8 @@ 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;
>  




More information about the linux-mtd mailing list