Re: [PATCH v2] pinctrl: stm32: check devm_kasprintf() returned value

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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

> 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




[Index of Archives]     [Linux SPI]     [Linux Kernel]     [Linux ARM (vger)]     [Linux ARM MSM]     [Linux Omap]     [Linux Arm]     [Linux Tegra]     [Fedora ARM]     [Linux for Samsung SOC]     [eCos]     [Linux Fastboot]     [Gcc Help]     [Git]     [DCCP]     [IETF Announce]     [Security]     [Linux MIPS]     [Yosemite Campsites]

  Powered by Linux