* [PATCH] Input: gpio-keys - fix unbalanced call pair for err handle
@ 2016-02-02 2:58 Shawn Lin
0 siblings, 0 replies; only message in thread
From: Shawn Lin @ 2016-02-02 2:58 UTC (permalink / raw)
To: Dmitry Torokhov; +Cc: Laxman Dewangan, linux-input, linux-kernel, Shawn Lin
If we fail to get pdata, we should not directly break
from the for_each_available_child_of_node since it calls of_node_get
while iterating. This patch add of_node_put to fix the unbalanced
call pair.
Signed-off-by: Shawn Lin <shawn.lin@rock-chips.com>
---
drivers/input/keyboard/gpio_keys.c | 12 +++++++++---
1 file changed, 9 insertions(+), 3 deletions(-)
diff --git a/drivers/input/keyboard/gpio_keys.c b/drivers/input/keyboard/gpio_keys.c
index 2909365..87744d3 100644
--- a/drivers/input/keyboard/gpio_keys.c
+++ b/drivers/input/keyboard/gpio_keys.c
@@ -661,7 +661,7 @@ gpio_keys_get_devtree_pdata(struct device *dev)
dev_err(dev,
"Failed to get gpio flags, error: %d\n",
error);
- return ERR_PTR(error);
+ goto err_out;
}
} else {
button->active_low = flags & OF_GPIO_ACTIVE_LOW;
@@ -671,13 +671,15 @@ gpio_keys_get_devtree_pdata(struct device *dev)
if (!gpio_is_valid(button->gpio) && !button->irq) {
dev_err(dev, "Found button without gpios or irqs\n");
- return ERR_PTR(-EINVAL);
+ error = -EINVAL;
+ goto err_out;
}
if (of_property_read_u32(pp, "linux,code", &button->code)) {
dev_err(dev, "Button without keycode: 0x%x\n",
button->gpio);
- return ERR_PTR(-EINVAL);
+ error = -EINVAL;
+ goto err_out;
}
button->desc = of_get_property(pp, "label", NULL);
@@ -700,6 +702,10 @@ gpio_keys_get_devtree_pdata(struct device *dev)
return ERR_PTR(-EINVAL);
return pdata;
+
+err_out:
+ of_node_put(pp);
+ return ERR_PTR(error);
}
static const struct of_device_id gpio_keys_of_match[] = {
--
2.3.7
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2016-02-02 3:03 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-02-02 2:58 [PATCH] Input: gpio-keys - fix unbalanced call pair for err handle Shawn Lin
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).