2021-10-21 11:27:52

by Jiabing Wan

[permalink] [raw]
Subject: [PATCH] iio: adc: stm32-adc: Fix of_node_put() issue in stm32-adc

Fix following coccicheck warning:
./drivers/iio/adc/stm32-adc.c:2014:1-33: WARNING: Function
for_each_available_child_of_node should have of_node_put() before return.

Early exits from for_each_available_child_of_node should decrement the
node reference counter. Replce return by goto here.

Signed-off-by: Wan Jiabing <[email protected]>
---
drivers/iio/adc/stm32-adc.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/iio/adc/stm32-adc.c b/drivers/iio/adc/stm32-adc.c
index 6245434f8377..7f1fb36c747c 100644
--- a/drivers/iio/adc/stm32-adc.c
+++ b/drivers/iio/adc/stm32-adc.c
@@ -2024,7 +2024,8 @@ static int stm32_adc_generic_chan_init(struct iio_dev *indio_dev,
if (strlen(name) >= STM32_ADC_CH_SZ) {
dev_err(&indio_dev->dev, "Label %s exceeds %d characters\n",
name, STM32_ADC_CH_SZ);
- return -EINVAL;
+ ret = -EINVAL;
+ goto err;
}
strncpy(adc->chan_name[val], name, STM32_ADC_CH_SZ);
ret = stm32_adc_populate_int_ch(indio_dev, name, val);
--
2.20.1


2021-10-21 12:06:16

by Fabrice Gasnier

[permalink] [raw]
Subject: Re: [PATCH] iio: adc: stm32-adc: Fix of_node_put() issue in stm32-adc

On 10/21/21 1:24 PM, Wan Jiabing wrote:
> Fix following coccicheck warning:
> ./drivers/iio/adc/stm32-adc.c:2014:1-33: WARNING: Function
> for_each_available_child_of_node should have of_node_put() before return.
>
> Early exits from for_each_available_child_of_node should decrement the
> node reference counter. Replce return by goto here.

Hi Wan,

typo: Replace

I guess there's no need for a Fixes tag. (I'm pretty sure Jonathan will
advise on this if needed).

>
> Signed-off-by: Wan Jiabing <[email protected]>

Apart from that, you can add my:
Reviewed-by: Fabrice Gasnier <[email protected]>

Thanks for the fix,
Best Regards,
Fabrice

> ---
> drivers/iio/adc/stm32-adc.c | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/iio/adc/stm32-adc.c b/drivers/iio/adc/stm32-adc.c
> index 6245434f8377..7f1fb36c747c 100644
> --- a/drivers/iio/adc/stm32-adc.c
> +++ b/drivers/iio/adc/stm32-adc.c
> @@ -2024,7 +2024,8 @@ static int stm32_adc_generic_chan_init(struct iio_dev *indio_dev,
> if (strlen(name) >= STM32_ADC_CH_SZ) {
> dev_err(&indio_dev->dev, "Label %s exceeds %d characters\n",
> name, STM32_ADC_CH_SZ);
> - return -EINVAL;
> + ret = -EINVAL;
> + goto err;
> }
> strncpy(adc->chan_name[val], name, STM32_ADC_CH_SZ);
> ret = stm32_adc_populate_int_ch(indio_dev, name, val);
>