Skip to content

Commit 0860913

Browse files
committed
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>
1 parent f9645f2 commit 0860913

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

drivers/input/keyboard/gpio_keys.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -659,6 +659,7 @@ gpio_keys_get_devtree_pdata(struct device *dev)
659659
dev_err(dev,
660660
"Failed to get gpio flags, error: %d\n",
661661
error);
662+
of_node_put(pp);
662663
return ERR_PTR(error);
663664
}
664665
} else {
@@ -669,12 +670,14 @@ gpio_keys_get_devtree_pdata(struct device *dev)
669670

670671
if (!gpio_is_valid(button->gpio) && !button->irq) {
671672
dev_err(dev, "Found button without gpios or irqs\n");
673+
of_node_put(pp);
672674
return ERR_PTR(-EINVAL);
673675
}
674676

675677
if (of_property_read_u32(pp, "linux,code", &button->code)) {
676678
dev_err(dev, "Button without keycode: 0x%x\n",
677679
button->gpio);
680+
of_node_put(pp);
678681
return ERR_PTR(-EINVAL);
679682
}
680683

0 commit comments

Comments
 (0)