All of lore.kernel.org
 help / color / mirror / Atom feed
From: Peng Wu <wupeng58@huawei.com>
To: <j.neuschaefer@gmx.net>, <linus.walleij@linaro.org>
Cc: <openbmc@lists.ozlabs.org>, <linux-gpio@vger.kernel.org>,
	<linux-kernel@vger.kernel.org>, <wupeng58@huawei.com>,
	<liwei391@huawei.com>
Subject: [PATCH] pinctrl: nuvoton: Add missing fwnode_handle_put in wpcm450_gpio_register
Date: Thu, 21 Apr 2022 05:53:56 +0000	[thread overview]
Message-ID: <20220421055356.8163-1-wupeng58@huawei.com> (raw)

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


WARNING: multiple messages have this Message-ID (diff)
From: Peng Wu <wupeng58@huawei.com>
To: <j.neuschaefer@gmx.net>, <linus.walleij@linaro.org>
Cc: wupeng58@huawei.com, linux-gpio@vger.kernel.org,
	openbmc@lists.ozlabs.org, liwei391@huawei.com,
	linux-kernel@vger.kernel.org
Subject: [PATCH] pinctrl: nuvoton: Add missing fwnode_handle_put in wpcm450_gpio_register
Date: Thu, 21 Apr 2022 05:53:56 +0000	[thread overview]
Message-ID: <20220421055356.8163-1-wupeng58@huawei.com> (raw)

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


             reply	other threads:[~2022-04-21  5:58 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-04-21  5:53 Peng Wu [this message]
2022-04-21  5:53 ` [PATCH] pinctrl: nuvoton: Add missing fwnode_handle_put in wpcm450_gpio_register Peng Wu
2022-04-21  7:32 ` Jonathan Neuschäfer
2022-04-21  7:32   ` Jonathan Neuschäfer

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=20220421055356.8163-1-wupeng58@huawei.com \
    --to=wupeng58@huawei.com \
    --cc=j.neuschaefer@gmx.net \
    --cc=linus.walleij@linaro.org \
    --cc=linux-gpio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=liwei391@huawei.com \
    --cc=openbmc@lists.ozlabs.org \
    /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 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.