[PATCH] Input: gpio-keys - fix unbalanced call pair for err handle

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxxxxxxx>
---

 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


--
To unsubscribe from this list: send the line "unsubscribe linux-input" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Linux Media Devel]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Linux Wireless Networking]     [Linux Omap]

  Powered by Linux