From: Michael Ellerman <mpe@ellerman.id.au>
To: Yi Yang <yiyang13@huawei.com>,
miquel.raynal@bootlin.com, richard@nod.at, vigneshr@ti.com,
npiggin@gmail.com, christophe.leroy@csgroup.eu,
u.kleine-koenig@pengutronix.de, tudor.ambarus@linaro.org,
robh@kernel.org
Cc: linux-mtd@lists.infradead.org, linuxppc-dev@lists.ozlabs.org
Subject: Re: [PATCH] mtd: powernv_flash: check return value of devm_kasprintf()
Date: Thu, 19 Oct 2023 12:16:17 +1100 [thread overview]
Message-ID: <874jin76ou.fsf@mail.lhotse> (raw)
In-Reply-To: <20231018092728.315071-1-yiyang13@huawei.com>
Yi Yang <yiyang13@huawei.com> writes:
> The devm_kasprintf() returns a pointer to dynamically allocated memory.
> that will return NULL when allocate failed.
> Fix it by check return value of devm_kasprintf().
>
> Fixes: acfe63ec1c59 ("mtd: Convert to using %pOFn instead of device_node.name")
> Signed-off-by: Yi Yang <yiyang13@huawei.com>
> ---
> drivers/mtd/devices/powernv_flash.c | 4 ++++
> 1 file changed, 4 insertions(+)
>
> diff --git a/drivers/mtd/devices/powernv_flash.c b/drivers/mtd/devices/powernv_flash.c
> index 66044f4f5bad..b305e555ddbf 100644
> --- a/drivers/mtd/devices/powernv_flash.c
> +++ b/drivers/mtd/devices/powernv_flash.c
> @@ -207,6 +207,10 @@ static int powernv_flash_set_driver_info(struct device *dev,
> * get them
> */
> mtd->name = devm_kasprintf(dev, GFP_KERNEL, "%pOFP", dev->of_node);
> + if (mtd->name) {
That seems like the wrong check?
cheers
> + dev_err(dev, "failed to allocate mtd->name\n");
> + return -ENOMEM;
> + }
> mtd->type = MTD_NORFLASH;
> mtd->flags = MTD_WRITEABLE;
> mtd->size = size;
> --
> 2.25.1
______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/
next prev parent reply other threads:[~2023-10-19 1:16 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-10-18 9:27 [PATCH] mtd: powernv_flash: check return value of devm_kasprintf() Yi Yang
2023-10-19 1:16 ` Michael Ellerman [this message]
2023-10-19 1:26 ` yiyang (D)
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=874jin76ou.fsf@mail.lhotse \
--to=mpe@ellerman.id.au \
--cc=christophe.leroy@csgroup.eu \
--cc=linux-mtd@lists.infradead.org \
--cc=linuxppc-dev@lists.ozlabs.org \
--cc=miquel.raynal@bootlin.com \
--cc=npiggin@gmail.com \
--cc=richard@nod.at \
--cc=robh@kernel.org \
--cc=tudor.ambarus@linaro.org \
--cc=u.kleine-koenig@pengutronix.de \
--cc=vigneshr@ti.com \
--cc=yiyang13@huawei.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox