linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: "yiyang (D)" <yiyang13@huawei.com>
To: Miquel Raynal <miquel.raynal@bootlin.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: Thu, 19 Oct 2023 09:23:17 +0800	[thread overview]
Message-ID: <6b2016de-c278-c459-f0a8-e96b97ed52ef@huawei.com> (raw)
In-Reply-To: <20231018141936.42b5ec6b@xps-13>

On 2023/10/18 20:19, Miquel Raynal wrote:
> 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.
> "
> 
Thanks for your advice, I'll make changes in v2 patch.

>> 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
> .
> 

Thanks,
Yi yang


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

      reply	other threads:[~2023-10-19  1:24 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
2023-10-19  1:23   ` yiyang (D) [this message]

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=6b2016de-c278-c459-f0a8-e96b97ed52ef@huawei.com \
    --to=yiyang13@huawei.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=miquel.raynal@bootlin.com \
    --cc=neil.armstrong@linaro.org \
    --cc=richard@nod.at \
    --cc=vigneshr@ti.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).