linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH V2] pinctrl: sirf: add missing put_device() call in sirfsoc_gpio_probe()
@ 2020-06-03  1:35 yu kuai
  2020-06-03  1:39 ` yukuai (C)
  2020-06-03 12:32 ` Linus Walleij
  0 siblings, 2 replies; 3+ messages in thread
From: yu kuai @ 2020-06-03  1:35 UTC (permalink / raw)
  To: linus.walleij, baohua, yuping.luo, Markus.Elfring
  Cc: linux-gpio, linux-arm-kernel, linux-kernel, yukuai3, yi.zhang

A coccicheck run provided information like the following:

drivers/pinctrl/sirf/pinctrl-sirf.c:798:2-8: ERROR: missing put_device;
call of_find_device_by_node on line 792, but without a corresponding
object release within this function.

Generated by: scripts/coccinelle/free/put_device.cocci

Thus add a jump target to fix the exception handling for this
function implementation.

Fixes: 5130216265f6 ("PINCTRL: SiRF: add GPIO and GPIO irq support in CSR SiRFprimaII")
Signed-off-by: yu kuai <yukuai3@huawei.com>
---
 drivers/pinctrl/sirf/pinctrl-sirf.c | 20 ++++++++++++++------
 1 file changed, 14 insertions(+), 6 deletions(-)

diff --git a/drivers/pinctrl/sirf/pinctrl-sirf.c b/drivers/pinctrl/sirf/pinctrl-sirf.c
index 1ebcb957c654..63a287d5795f 100644
--- a/drivers/pinctrl/sirf/pinctrl-sirf.c
+++ b/drivers/pinctrl/sirf/pinctrl-sirf.c
@@ -794,13 +794,17 @@ static int sirfsoc_gpio_probe(struct device_node *np)
 		return -ENODEV;
 
 	sgpio = devm_kzalloc(&pdev->dev, sizeof(*sgpio), GFP_KERNEL);
-	if (!sgpio)
-		return -ENOMEM;
+	if (!sgpio) {
+		err = -ENOMEM;
+		goto out_put_device;
+	}
 	spin_lock_init(&sgpio->lock);
 
 	regs = of_iomap(np, 0);
-	if (!regs)
-		return -ENOMEM;
+	if (!regs) {
+		err = -ENOMEM;
+		goto out_put_device;
+	}
 
 	sgpio->chip.gc.request = sirfsoc_gpio_request;
 	sgpio->chip.gc.free = sirfsoc_gpio_free;
@@ -824,8 +828,10 @@ static int sirfsoc_gpio_probe(struct device_node *np)
 	girq->parents = devm_kcalloc(&pdev->dev, SIRFSOC_GPIO_NO_OF_BANKS,
 				     sizeof(*girq->parents),
 				     GFP_KERNEL);
-	if (!girq->parents)
-		return -ENOMEM;
+	if (!girq->parents) {
+		err = -ENOMEM;
+		goto out_put_device;
+	}
 	for (i = 0; i < SIRFSOC_GPIO_NO_OF_BANKS; i++) {
 		bank = &sgpio->sgpio_bank[i];
 		spin_lock_init(&bank->lock);
@@ -868,6 +874,8 @@ static int sirfsoc_gpio_probe(struct device_node *np)
 	gpiochip_remove(&sgpio->chip.gc);
 out:
 	iounmap(regs);
+out_put_device:
+	put_device(&pdev->dev);
 	return err;
 }
 
-- 
2.25.4


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

* Re: [PATCH V2] pinctrl: sirf: add missing put_device() call in sirfsoc_gpio_probe()
  2020-06-03  1:35 [PATCH V2] pinctrl: sirf: add missing put_device() call in sirfsoc_gpio_probe() yu kuai
@ 2020-06-03  1:39 ` yukuai (C)
  2020-06-03 12:32 ` Linus Walleij
  1 sibling, 0 replies; 3+ messages in thread
From: yukuai (C) @ 2020-06-03  1:39 UTC (permalink / raw)
  To: linus.walleij, baohua, yuping.luo, Markus.Elfring
  Cc: linux-gpio, linux-arm-kernel, linux-kernel, yi.zhang

On 2020/6/3 9:35, yu kuai wrote:
> A coccicheck run provided information like the following:
> 
> drivers/pinctrl/sirf/pinctrl-sirf.c:798:2-8: ERROR: missing put_device;
> call of_find_device_by_node on line 792, but without a corresponding
> object release within this function.
> 
> Generated by: scripts/coccinelle/free/put_device.cocci
> 
> Thus add a jump target to fix the exception handling for this
> function implementation.
> 
> Fixes: 5130216265f6 ("PINCTRL: SiRF: add GPIO and GPIO irq support in CSR SiRFprimaII")
> Signed-off-by: yu kuai <yukuai3@huawei.com>
> ---
>   drivers/pinctrl/sirf/pinctrl-sirf.c | 20 ++++++++++++++------
>   1 file changed, 14 insertions(+), 6 deletions(-)
Sorry about the missing change log:

Changes in V2:
  change the variant of commit message suggested by Markus.

Best Regards,
Yu Kuai


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

* Re: [PATCH V2] pinctrl: sirf: add missing put_device() call in sirfsoc_gpio_probe()
  2020-06-03  1:35 [PATCH V2] pinctrl: sirf: add missing put_device() call in sirfsoc_gpio_probe() yu kuai
  2020-06-03  1:39 ` yukuai (C)
@ 2020-06-03 12:32 ` Linus Walleij
  1 sibling, 0 replies; 3+ messages in thread
From: Linus Walleij @ 2020-06-03 12:32 UTC (permalink / raw)
  To: yu kuai
  Cc: Barry Song, Yuping Luo, Markus Elfring, open list:GPIO SUBSYSTEM,
	Linux ARM, linux-kernel, yi.zhang

On Wed, Jun 3, 2020 at 3:36 AM yu kuai <yukuai3@huawei.com> wrote:

> A coccicheck run provided information like the following:
>
> drivers/pinctrl/sirf/pinctrl-sirf.c:798:2-8: ERROR: missing put_device;
> call of_find_device_by_node on line 792, but without a corresponding
> object release within this function.
>
> Generated by: scripts/coccinelle/free/put_device.cocci
>
> Thus add a jump target to fix the exception handling for this
> function implementation.
>
> Fixes: 5130216265f6 ("PINCTRL: SiRF: add GPIO and GPIO irq support in CSR SiRFprimaII")
> Signed-off-by: yu kuai <yukuai3@huawei.com>

Patch applied, thanks!

Yours,
Linus Walleij

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

end of thread, other threads:[~2020-06-03 12:33 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-06-03  1:35 [PATCH V2] pinctrl: sirf: add missing put_device() call in sirfsoc_gpio_probe() yu kuai
2020-06-03  1:39 ` yukuai (C)
2020-06-03 12:32 ` Linus Walleij

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).