linux-gpio.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
To: Ma Ke <make24@iscas.ac.cn>,
	marcan@marcan.st, sven@svenpeter.dev, alyssa@rosenzweig.io,
	linus.walleij@linaro.org, joey.gouly@arm.com, stan@corellium.com,
	maz@kernel.org, akpm@linux-foundation.org
Cc: asahi@lists.linux.dev, linux-arm-kernel@lists.infradead.org,
	linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org,
	stable@vger.kernel.org
Subject: Re: [PATCH RESEND] pinctrl: check devm_kasprintf() returned value
Date: Fri, 13 Sep 2024 07:26:12 +0200	[thread overview]
Message-ID: <3efdd5c8-84e9-4beb-811c-65db48e9af2b@wanadoo.fr> (raw)
In-Reply-To: <20240912020840.1763252-1-make24@iscas.ac.cn>

Le 12/09/2024 à 04:08, Ma Ke a écrit :
> devm_kasprintf() can return a NULL pointer on failure but this returned
> value is not checked. Fix this lack and check the returned value.
> 
> Found by code review.
> 
> Cc: stable@vger.kernel.org
> Fixes: a0f160ffcb83 ("pinctrl: add pinctrl/GPIO driver for Apple SoCs")
> Signed-off-by: Ma Ke <make24@iscas.ac.cn>
> ---
>   drivers/pinctrl/pinctrl-apple-gpio.c | 3 +++
>   1 file changed, 3 insertions(+)
> 
> diff --git a/drivers/pinctrl/pinctrl-apple-gpio.c b/drivers/pinctrl/pinctrl-apple-gpio.c
> index 3751c7de37aa..f861e63f4115 100644
> --- a/drivers/pinctrl/pinctrl-apple-gpio.c
> +++ b/drivers/pinctrl/pinctrl-apple-gpio.c
> @@ -474,6 +474,9 @@ static int apple_gpio_pinctrl_probe(struct platform_device *pdev)
>   	for (i = 0; i < npins; i++) {
>   		pins[i].number = i;
>   		pins[i].name = devm_kasprintf(&pdev->dev, GFP_KERNEL, "PIN%u", i);
> +		if (!pins[i].name)
> +			return -ENOMEM;
> +
>   		pins[i].drv_data = pctl;
>   		pin_names[i] = pins[i].name;
>   		pin_nums[i] = i;

Hi,

this is not really an issue. if pin[i].name is NULL, then 
pinctrl_generic_add_group() below will fail with -EINVAL.
So your change only returns a more correct error code and saves a few 
cycles in case of (unlikely) memory allocation issue.

Anyway:
Reviewed-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>

CJ



      reply	other threads:[~2024-09-13  5:26 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-09-12  2:08 [PATCH RESEND] pinctrl: check devm_kasprintf() returned value Ma Ke
2024-09-13  5:26 ` Christophe JAILLET [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=3efdd5c8-84e9-4beb-811c-65db48e9af2b@wanadoo.fr \
    --to=christophe.jaillet@wanadoo.fr \
    --cc=akpm@linux-foundation.org \
    --cc=alyssa@rosenzweig.io \
    --cc=asahi@lists.linux.dev \
    --cc=joey.gouly@arm.com \
    --cc=linus.walleij@linaro.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-gpio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=make24@iscas.ac.cn \
    --cc=marcan@marcan.st \
    --cc=maz@kernel.org \
    --cc=stable@vger.kernel.org \
    --cc=stan@corellium.com \
    --cc=sven@svenpeter.dev \
    /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).