summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDmitry Torokhov <dmitry.torokhov@gmail.com>2016-10-20 15:11:45 -0700
committerDmitry Torokhov <dmitry.torokhov@gmail.com>2016-11-07 16:24:30 -0800
commit0860913b02c28f0a1d8b515b99ae6419ef10569f (patch)
tree826c999a5cc5771dd6872e3d7cfa32e28053e50a
parentf9645f22584250336a99a23bc9e444396b5bc323 (diff)
Input: gpio_keys - fix leaking DT node references
for_each_available_child_of_node(node, pp) takes reference to 'pp' and drops it when attempting next iteration. However if we exit the loop early we need to drop the reference ourselves. Tested-by: Mika Westerberg <mika.westerberg@linux.intel.com> Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
-rw-r--r--drivers/input/keyboard/gpio_keys.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/drivers/input/keyboard/gpio_keys.c b/drivers/input/keyboard/gpio_keys.c
index 8f7c20b9cc5c..d75a25c187ae 100644
--- a/drivers/input/keyboard/gpio_keys.c
+++ b/drivers/input/keyboard/gpio_keys.c
@@ -659,6 +659,7 @@ gpio_keys_get_devtree_pdata(struct device *dev)
dev_err(dev,
"Failed to get gpio flags, error: %d\n",
error);
+ of_node_put(pp);
return ERR_PTR(error);
}
} else {
@@ -669,12 +670,14 @@ 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");
+ of_node_put(pp);
return ERR_PTR(-EINVAL);
}
if (of_property_read_u32(pp, "linux,code", &button->code)) {
dev_err(dev, "Button without keycode: 0x%x\n",
button->gpio);
+ of_node_put(pp);
return ERR_PTR(-EINVAL);
}