All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] pinctrl: nuvoton: Add missing fwnode_handle_put in wpcm450_gpio_register
@ 2022-04-21  5:53 ` Peng Wu
  0 siblings, 0 replies; 4+ messages in thread
From: Peng Wu @ 2022-04-21  5:53 UTC (permalink / raw)
  To: j.neuschaefer, linus.walleij
  Cc: openbmc, linux-gpio, linux-kernel, wupeng58, liwei391

In one of the error paths of the device_for_each_child_node() loop
in wpcm450_gpio_register, add missing call to fwnode_handle_put.

Signed-off-by: Peng Wu <wupeng58@huawei.com>
---
 drivers/pinctrl/nuvoton/pinctrl-wpcm450.c | 23 +++++++++++++++++------
 1 file changed, 17 insertions(+), 6 deletions(-)

diff --git a/drivers/pinctrl/nuvoton/pinctrl-wpcm450.c b/drivers/pinctrl/nuvoton/pinctrl-wpcm450.c
index 0dbeb91f0bf2..de4388b512d7 100644
--- a/drivers/pinctrl/nuvoton/pinctrl-wpcm450.c
+++ b/drivers/pinctrl/nuvoton/pinctrl-wpcm450.c
@@ -1038,15 +1038,19 @@ static int wpcm450_gpio_register(struct platform_device *pdev,
 			continue;
 
 		ret = fwnode_property_read_u32(child, "reg", &reg);
-		if (ret < 0)
+		if (ret < 0) {
+			fwnode_handle_put(child);
 			return ret;
+		}
 
 		gpio = &pctrl->gpio_bank[reg];
 		gpio->pctrl = pctrl;
 
-		if (reg >= WPCM450_NUM_BANKS)
+		if (reg >= WPCM450_NUM_BANKS) {
+			fwnode_handle_put(child);
 			return dev_err_probe(dev, -EINVAL,
-					     "GPIO index %d out of range!\n", reg);
+					"GPIO index %d out of range!\n", reg);
+		}
 
 		bank = &wpcm450_banks[reg];
 		gpio->bank = bank;
@@ -1060,8 +1064,10 @@ static int wpcm450_gpio_register(struct platform_device *pdev,
 		}
 		ret = bgpio_init(&gpio->gc, dev, 4,
 				 dat, set, NULL, dirout, NULL, flags);
-		if (ret < 0)
+		if (ret < 0) {
+			fwnode_handle_put(child);
 			return dev_err_probe(dev, ret, "GPIO initialization failed\n");
+		}
 
 		gpio->gc.ngpio = bank->length;
 		gpio->gc.set_config = wpcm450_gpio_set_config;
@@ -1074,8 +1080,11 @@ static int wpcm450_gpio_register(struct platform_device *pdev,
 		girq->parent_handler = wpcm450_gpio_irqhandler;
 		girq->parents = devm_kcalloc(dev, WPCM450_NUM_GPIO_IRQS,
 					     sizeof(*girq->parents), GFP_KERNEL);
-		if (!girq->parents)
+		if (!girq->parents) {
+			fwnode_handle_put(child);
 			return -ENOMEM;
+		}
+
 		girq->default_type = IRQ_TYPE_NONE;
 		girq->handler = handle_bad_irq;
 
@@ -1091,8 +1100,10 @@ static int wpcm450_gpio_register(struct platform_device *pdev,
 		}
 
 		ret = devm_gpiochip_add_data(dev, &gpio->gc, gpio);
-		if (ret)
+		if (ret) {
+			fwnode_handle_put(child);
 			return dev_err_probe(dev, ret, "Failed to add GPIO chip\n");
+		}
 	}
 
 	return 0;
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH] pinctrl: nuvoton: Add missing fwnode_handle_put in wpcm450_gpio_register
@ 2022-04-21  5:53 ` Peng Wu
  0 siblings, 0 replies; 4+ messages in thread
From: Peng Wu @ 2022-04-21  5:53 UTC (permalink / raw)
  To: j.neuschaefer, linus.walleij
  Cc: wupeng58, linux-gpio, openbmc, liwei391, linux-kernel

In one of the error paths of the device_for_each_child_node() loop
in wpcm450_gpio_register, add missing call to fwnode_handle_put.

Signed-off-by: Peng Wu <wupeng58@huawei.com>
---
 drivers/pinctrl/nuvoton/pinctrl-wpcm450.c | 23 +++++++++++++++++------
 1 file changed, 17 insertions(+), 6 deletions(-)

diff --git a/drivers/pinctrl/nuvoton/pinctrl-wpcm450.c b/drivers/pinctrl/nuvoton/pinctrl-wpcm450.c
index 0dbeb91f0bf2..de4388b512d7 100644
--- a/drivers/pinctrl/nuvoton/pinctrl-wpcm450.c
+++ b/drivers/pinctrl/nuvoton/pinctrl-wpcm450.c
@@ -1038,15 +1038,19 @@ static int wpcm450_gpio_register(struct platform_device *pdev,
 			continue;
 
 		ret = fwnode_property_read_u32(child, "reg", &reg);
-		if (ret < 0)
+		if (ret < 0) {
+			fwnode_handle_put(child);
 			return ret;
+		}
 
 		gpio = &pctrl->gpio_bank[reg];
 		gpio->pctrl = pctrl;
 
-		if (reg >= WPCM450_NUM_BANKS)
+		if (reg >= WPCM450_NUM_BANKS) {
+			fwnode_handle_put(child);
 			return dev_err_probe(dev, -EINVAL,
-					     "GPIO index %d out of range!\n", reg);
+					"GPIO index %d out of range!\n", reg);
+		}
 
 		bank = &wpcm450_banks[reg];
 		gpio->bank = bank;
@@ -1060,8 +1064,10 @@ static int wpcm450_gpio_register(struct platform_device *pdev,
 		}
 		ret = bgpio_init(&gpio->gc, dev, 4,
 				 dat, set, NULL, dirout, NULL, flags);
-		if (ret < 0)
+		if (ret < 0) {
+			fwnode_handle_put(child);
 			return dev_err_probe(dev, ret, "GPIO initialization failed\n");
+		}
 
 		gpio->gc.ngpio = bank->length;
 		gpio->gc.set_config = wpcm450_gpio_set_config;
@@ -1074,8 +1080,11 @@ static int wpcm450_gpio_register(struct platform_device *pdev,
 		girq->parent_handler = wpcm450_gpio_irqhandler;
 		girq->parents = devm_kcalloc(dev, WPCM450_NUM_GPIO_IRQS,
 					     sizeof(*girq->parents), GFP_KERNEL);
-		if (!girq->parents)
+		if (!girq->parents) {
+			fwnode_handle_put(child);
 			return -ENOMEM;
+		}
+
 		girq->default_type = IRQ_TYPE_NONE;
 		girq->handler = handle_bad_irq;
 
@@ -1091,8 +1100,10 @@ static int wpcm450_gpio_register(struct platform_device *pdev,
 		}
 
 		ret = devm_gpiochip_add_data(dev, &gpio->gc, gpio);
-		if (ret)
+		if (ret) {
+			fwnode_handle_put(child);
 			return dev_err_probe(dev, ret, "Failed to add GPIO chip\n");
+		}
 	}
 
 	return 0;
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] pinctrl: nuvoton: Add missing fwnode_handle_put in wpcm450_gpio_register
  2022-04-21  5:53 ` Peng Wu
@ 2022-04-21  7:32   ` Jonathan Neuschäfer
  -1 siblings, 0 replies; 4+ messages in thread
From: Jonathan Neuschäfer @ 2022-04-21  7:32 UTC (permalink / raw)
  To: Peng Wu
  Cc: j.neuschaefer, linus.walleij, openbmc, linux-gpio, linux-kernel,
	liwei391

[-- Attachment #1: Type: text/plain, Size: 3186 bytes --]

Hello,

thank you for your patch!

On Thu, Apr 21, 2022 at 05:53:56AM +0000, Peng Wu wrote:
> In one of the error paths of the device_for_each_child_node() loop
> in wpcm450_gpio_register, add missing call to fwnode_handle_put.

Your patch changes multiple error patches, not just one of them. Please
change the commit message accordingly.

To make it easier to understand for the unfamiliar, please also mention:
- Where fwnode is acquired (in device_for_each_child_node?)
- Where the fwnode is released or used in the success (non-error) path.
  I think (part of) the answer is: It is assigned to gpio->gc.fwnode

> 
> Signed-off-by: Peng Wu <wupeng58@huawei.com>
> ---
>  drivers/pinctrl/nuvoton/pinctrl-wpcm450.c | 23 +++++++++++++++++------
>  1 file changed, 17 insertions(+), 6 deletions(-)
> 
> diff --git a/drivers/pinctrl/nuvoton/pinctrl-wpcm450.c b/drivers/pinctrl/nuvoton/pinctrl-wpcm450.c
> index 0dbeb91f0bf2..de4388b512d7 100644
> --- a/drivers/pinctrl/nuvoton/pinctrl-wpcm450.c
> +++ b/drivers/pinctrl/nuvoton/pinctrl-wpcm450.c
> @@ -1038,15 +1038,19 @@ static int wpcm450_gpio_register(struct platform_device *pdev,
>  		if (!fwnode_property_read_bool(child, "gpio-controller"))
>  			continue;

Does the 'continue' also need a fwnode_handle_put call?

>  
>  		ret = fwnode_property_read_u32(child, "reg", &reg);
> -		if (ret < 0)
> +		if (ret < 0) {
> +			fwnode_handle_put(child);
>  			return ret;
> +		}
>  
>  		gpio = &pctrl->gpio_bank[reg];
>  		gpio->pctrl = pctrl;
>  
> -		if (reg >= WPCM450_NUM_BANKS)
> +		if (reg >= WPCM450_NUM_BANKS) {
> +			fwnode_handle_put(child);
>  			return dev_err_probe(dev, -EINVAL,
> -					     "GPIO index %d out of range!\n", reg);
> +					"GPIO index %d out of range!\n", reg);

Please leave the indentation as is, in this line.

> +		}
>  
>  		bank = &wpcm450_banks[reg];
>  		gpio->bank = bank;
> @@ -1060,8 +1064,10 @@ static int wpcm450_gpio_register(struct platform_device *pdev,
>  		}
>  		ret = bgpio_init(&gpio->gc, dev, 4,
>  				 dat, set, NULL, dirout, NULL, flags);
> -		if (ret < 0)
> +		if (ret < 0) {
> +			fwnode_handle_put(child);
>  			return dev_err_probe(dev, ret, "GPIO initialization failed\n");
> +		}
>  
>  		gpio->gc.ngpio = bank->length;
>  		gpio->gc.set_config = wpcm450_gpio_set_config;
> @@ -1074,8 +1080,11 @@ static int wpcm450_gpio_register(struct platform_device *pdev,
>  		girq->parent_handler = wpcm450_gpio_irqhandler;
>  		girq->parents = devm_kcalloc(dev, WPCM450_NUM_GPIO_IRQS,
>  					     sizeof(*girq->parents), GFP_KERNEL);
> -		if (!girq->parents)
> +		if (!girq->parents) {
> +			fwnode_handle_put(child);
>  			return -ENOMEM;
> +		}
> +
>  		girq->default_type = IRQ_TYPE_NONE;
>  		girq->handler = handle_bad_irq;
>  
> @@ -1091,8 +1100,10 @@ static int wpcm450_gpio_register(struct platform_device *pdev,
>  		}
>  
>  		ret = devm_gpiochip_add_data(dev, &gpio->gc, gpio);
> -		if (ret)
> +		if (ret) {
> +			fwnode_handle_put(child);
>  			return dev_err_probe(dev, ret, "Failed to add GPIO chip\n");
> +		}
>  	}
>  
>  	return 0;
> -- 
> 2.17.1
> 


Thanks,
Jonathan

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] pinctrl: nuvoton: Add missing fwnode_handle_put in wpcm450_gpio_register
@ 2022-04-21  7:32   ` Jonathan Neuschäfer
  0 siblings, 0 replies; 4+ messages in thread
From: Jonathan Neuschäfer @ 2022-04-21  7:32 UTC (permalink / raw)
  To: Peng Wu
  Cc: linus.walleij, j.neuschaefer, linux-kernel, linux-gpio, liwei391,
	openbmc

[-- Attachment #1: Type: text/plain, Size: 3186 bytes --]

Hello,

thank you for your patch!

On Thu, Apr 21, 2022 at 05:53:56AM +0000, Peng Wu wrote:
> In one of the error paths of the device_for_each_child_node() loop
> in wpcm450_gpio_register, add missing call to fwnode_handle_put.

Your patch changes multiple error patches, not just one of them. Please
change the commit message accordingly.

To make it easier to understand for the unfamiliar, please also mention:
- Where fwnode is acquired (in device_for_each_child_node?)
- Where the fwnode is released or used in the success (non-error) path.
  I think (part of) the answer is: It is assigned to gpio->gc.fwnode

> 
> Signed-off-by: Peng Wu <wupeng58@huawei.com>
> ---
>  drivers/pinctrl/nuvoton/pinctrl-wpcm450.c | 23 +++++++++++++++++------
>  1 file changed, 17 insertions(+), 6 deletions(-)
> 
> diff --git a/drivers/pinctrl/nuvoton/pinctrl-wpcm450.c b/drivers/pinctrl/nuvoton/pinctrl-wpcm450.c
> index 0dbeb91f0bf2..de4388b512d7 100644
> --- a/drivers/pinctrl/nuvoton/pinctrl-wpcm450.c
> +++ b/drivers/pinctrl/nuvoton/pinctrl-wpcm450.c
> @@ -1038,15 +1038,19 @@ static int wpcm450_gpio_register(struct platform_device *pdev,
>  		if (!fwnode_property_read_bool(child, "gpio-controller"))
>  			continue;

Does the 'continue' also need a fwnode_handle_put call?

>  
>  		ret = fwnode_property_read_u32(child, "reg", &reg);
> -		if (ret < 0)
> +		if (ret < 0) {
> +			fwnode_handle_put(child);
>  			return ret;
> +		}
>  
>  		gpio = &pctrl->gpio_bank[reg];
>  		gpio->pctrl = pctrl;
>  
> -		if (reg >= WPCM450_NUM_BANKS)
> +		if (reg >= WPCM450_NUM_BANKS) {
> +			fwnode_handle_put(child);
>  			return dev_err_probe(dev, -EINVAL,
> -					     "GPIO index %d out of range!\n", reg);
> +					"GPIO index %d out of range!\n", reg);

Please leave the indentation as is, in this line.

> +		}
>  
>  		bank = &wpcm450_banks[reg];
>  		gpio->bank = bank;
> @@ -1060,8 +1064,10 @@ static int wpcm450_gpio_register(struct platform_device *pdev,
>  		}
>  		ret = bgpio_init(&gpio->gc, dev, 4,
>  				 dat, set, NULL, dirout, NULL, flags);
> -		if (ret < 0)
> +		if (ret < 0) {
> +			fwnode_handle_put(child);
>  			return dev_err_probe(dev, ret, "GPIO initialization failed\n");
> +		}
>  
>  		gpio->gc.ngpio = bank->length;
>  		gpio->gc.set_config = wpcm450_gpio_set_config;
> @@ -1074,8 +1080,11 @@ static int wpcm450_gpio_register(struct platform_device *pdev,
>  		girq->parent_handler = wpcm450_gpio_irqhandler;
>  		girq->parents = devm_kcalloc(dev, WPCM450_NUM_GPIO_IRQS,
>  					     sizeof(*girq->parents), GFP_KERNEL);
> -		if (!girq->parents)
> +		if (!girq->parents) {
> +			fwnode_handle_put(child);
>  			return -ENOMEM;
> +		}
> +
>  		girq->default_type = IRQ_TYPE_NONE;
>  		girq->handler = handle_bad_irq;
>  
> @@ -1091,8 +1100,10 @@ static int wpcm450_gpio_register(struct platform_device *pdev,
>  		}
>  
>  		ret = devm_gpiochip_add_data(dev, &gpio->gc, gpio);
> -		if (ret)
> +		if (ret) {
> +			fwnode_handle_put(child);
>  			return dev_err_probe(dev, ret, "Failed to add GPIO chip\n");
> +		}
>  	}
>  
>  	return 0;
> -- 
> 2.17.1
> 


Thanks,
Jonathan

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2022-04-26  2:05 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-04-21  5:53 [PATCH] pinctrl: nuvoton: Add missing fwnode_handle_put in wpcm450_gpio_register Peng Wu
2022-04-21  5:53 ` Peng Wu
2022-04-21  7:32 ` Jonathan Neuschäfer
2022-04-21  7:32   ` Jonathan Neuschäfer

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.