linux-gpio.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Sergei Shtylyov <sergei.shtylyov@gmail.com>
To: Ma Ke <make24@iscas.ac.cn>,
	linus.walleij@linaro.org, mcoquelin.stm32@gmail.com,
	alexandre.torgue@foss.st.com, bartosz.golaszewski@linaro.org,
	antonio.borneo@foss.st.com, valentin.caron@foss.st.com,
	peng.fan@nxp.com, akpm@linux-foundation.org
Cc: linux-gpio@vger.kernel.org,
	linux-stm32@st-md-mailman.stormreply.com,
	linux-arm-kernel@lists.infradead.org,
	linux-kernel@vger.kernel.org, stable@vger.kernel.org
Subject: Re: [PATCH v2] pinctrl: stm32: check devm_kasprintf() returned value
Date: Fri, 6 Sep 2024 12:49:51 +0300	[thread overview]
Message-ID: <22a622cd-5f10-58cf-92e8-be3da31e127c@gmail.com> (raw)
In-Reply-To: <20240906020323.556593-1-make24@iscas.ac.cn>

On 9/6/24 5:03 AM, Ma Ke wrote:

> 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: 32c170ff15b0 ("pinctrl: stm32: set default gpio line names using pin names")
> Signed-off-by: Ma Ke <make24@iscas.ac.cn>
[...]

> diff --git a/drivers/pinctrl/stm32/pinctrl-stm32.c b/drivers/pinctrl/stm32/pinctrl-stm32.c
> index a8673739871d..f23b081f31b3 100644
> --- a/drivers/pinctrl/stm32/pinctrl-stm32.c
> +++ b/drivers/pinctrl/stm32/pinctrl-stm32.c
> @@ -1374,10 +1374,16 @@ static int stm32_gpiolib_register_bank(struct stm32_pinctrl *pctl, struct fwnode
>  
>  	for (i = 0; i < npins; i++) {
>  		stm32_pin = stm32_pctrl_get_desc_pin_from_gpio(pctl, bank, i);
> -		if (stm32_pin && stm32_pin->pin.name)
> +		if (stm32_pin && stm32_pin->pin.name) {
>  			names[i] = devm_kasprintf(dev, GFP_KERNEL, "%s", stm32_pin->pin.name);
> -		else
> +			if (!names[i]) {
> +				err = -ENOMEM;
> +				goto err_clk;
> +			}
> +		}
> +
> +		else {

   No, that should be:

		} else {

   See Documentation/process/coding-style.rst, section 3.

>  			names[i] = NULL;
> +		}
>  	}
[...]

MBR, Sergey

      reply	other threads:[~2024-09-06  9:49 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-09-06  2:03 [PATCH v2] pinctrl: stm32: check devm_kasprintf() returned value Ma Ke
2024-09-06  9:49 ` Sergei Shtylyov [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=22a622cd-5f10-58cf-92e8-be3da31e127c@gmail.com \
    --to=sergei.shtylyov@gmail.com \
    --cc=akpm@linux-foundation.org \
    --cc=alexandre.torgue@foss.st.com \
    --cc=antonio.borneo@foss.st.com \
    --cc=bartosz.golaszewski@linaro.org \
    --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=linux-stm32@st-md-mailman.stormreply.com \
    --cc=make24@iscas.ac.cn \
    --cc=mcoquelin.stm32@gmail.com \
    --cc=peng.fan@nxp.com \
    --cc=stable@vger.kernel.org \
    --cc=valentin.caron@foss.st.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).