From: Miquel Raynal <miquel.raynal@bootlin.com>
To: Yi Yang <yiyang13@huawei.com>
Cc: <liang.yang@amlogic.com>, <richard@nod.at>, <vigneshr@ti.com>,
<neil.armstrong@linaro.org>, <khilman@baylibre.com>,
<jbrunet@baylibre.com>, <martin.blumenstingl@googlemail.com>,
<linux-mtd@lists.infradead.org>,
<linux-arm-kernel@lists.infradead.org>,
<linux-amlogic@lists.infradead.org>
Subject: Re: [PATCH] mtd: rawnand: meson: check return value of devm_kasprintf()
Date: Wed, 18 Oct 2023 14:19:36 +0200 [thread overview]
Message-ID: <20231018141936.42b5ec6b@xps-13> (raw)
In-Reply-To: <20231018092047.314860-1-yiyang13@huawei.com>
Hi Yi,
yiyang13@huawei.com wrote on Wed, 18 Oct 2023 09:20:47 +0000:
> The devm_kasprintf() returns a pointer to dynamically allocated memory.
> that will return NULL when allocate failed.
May I propose rewording of the commit log?
"
devm_kasprintf() returns a pointer to dynamically allocated memory
which can be NULL upon failure. Ensure the allocation was successful by
checking the pointer validity.
"
> Fix it by check return value of devm_kasprintf().
>
> Fixes: 1e4d3ba66888 ("mtd: rawnand: meson: fix the clock")
> Signed-off-by: Yi Yang <yiyang13@huawei.com>
> ---
> drivers/mtd/nand/raw/meson_nand.c | 5 +++++
> 1 file changed, 5 insertions(+)
>
> diff --git a/drivers/mtd/nand/raw/meson_nand.c b/drivers/mtd/nand/raw/meson_nand.c
> index 378f28ce6a74..2c6ae781bb0c 100644
> --- a/drivers/mtd/nand/raw/meson_nand.c
> +++ b/drivers/mtd/nand/raw/meson_nand.c
> @@ -1134,6 +1134,11 @@ static int meson_nfc_clk_init(struct meson_nfc *nfc)
> init.name = devm_kasprintf(nfc->dev,
> GFP_KERNEL, "%s#div",
> dev_name(nfc->dev));
> + if (init.name) {
> + dev_err(nfc->dev, "failed to allocate init.name\n");
No need for error messages upon memory allocation failures.
> + return -ENOMEM;
> + }
> +
> init.ops = &clk_divider_ops;
> nfc_divider_parent_data[0].fw_name = "device";
> init.parent_data = nfc_divider_parent_data;
These comments are also applicable to your two other patches.
Thanks,
Miquèl
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
next prev parent reply other threads:[~2023-10-18 12:20 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-10-18 9:20 [PATCH] mtd: rawnand: meson: check return value of devm_kasprintf() Yi Yang
2023-10-18 12:19 ` Miquel Raynal [this message]
2023-10-19 1:23 ` 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=20231018141936.42b5ec6b@xps-13 \
--to=miquel.raynal@bootlin.com \
--cc=jbrunet@baylibre.com \
--cc=khilman@baylibre.com \
--cc=liang.yang@amlogic.com \
--cc=linux-amlogic@lists.infradead.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-mtd@lists.infradead.org \
--cc=martin.blumenstingl@googlemail.com \
--cc=neil.armstrong@linaro.org \
--cc=richard@nod.at \
--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;
as well as URLs for NNTP newsgroup(s).