Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1323749
| From | Shawn Lin <shawn.lin@rock-chips.com> |
|---|---|
| Newsgroups | linux.kernel |
| Subject | [PATCH] Input: gpio-keys - fix unbalanced call pair for err handle |
| Date | 2016-02-02 04:10 +0100 |
| Message-ID | <qXzvQ-4pr-5@gated-at.bofh.it> (permalink) |
| Organization | linux.* mail to news gateway |
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
Back to linux.kernel | Previous | Next | Find similar | Unroll thread
[PATCH] Input: gpio-keys - fix unbalanced call pair for err handle Shawn Lin <shawn.lin@rock-chips.com> - 2016-02-02 04:10 +0100
csiph-web