LinuxPPC-Dev Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: "yiyang (D)" <yiyang13@huawei.com>
To: Michael Ellerman <mpe@ellerman.id.au>,
	<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: linuxppc-dev@lists.ozlabs.org, linux-mtd@lists.infradead.org
Subject: Re: [PATCH] mtd: powernv_flash: check return value of devm_kasprintf()
Date: Thu, 19 Oct 2023 09:26:07 +0800	[thread overview]
Message-ID: <0aa58cef-182a-ba75-d362-822d434c67d3@huawei.com> (raw)
In-Reply-To: <874jin76ou.fsf@mail.lhotse>

On 2023/10/19 9:16, Michael Ellerman wrote:
> 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
> 
You're right, I'm fixing this in v2 patch.

Thanks,
Yi Yang

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


      reply	other threads:[~2023-10-19  1:26 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
2023-10-19  1:26   ` 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=0aa58cef-182a-ba75-d362-822d434c67d3@huawei.com \
    --to=yiyang13@huawei.com \
    --cc=christophe.leroy@csgroup.eu \
    --cc=linux-mtd@lists.infradead.org \
    --cc=linuxppc-dev@lists.ozlabs.org \
    --cc=miquel.raynal@bootlin.com \
    --cc=mpe@ellerman.id.au \
    --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 \
    /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