Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 0860913b authored by Dmitry Torokhov's avatar Dmitry Torokhov
Browse files

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: default avatarMika Westerberg <mika.westerberg@linux.intel.com>
Signed-off-by: default avatarDmitry Torokhov <dmitry.torokhov@gmail.com>
parent f9645f22
Loading
Loading
Loading
Loading
+3 −0
Original line number Original line Diff line number Diff line
@@ -659,6 +659,7 @@ gpio_keys_get_devtree_pdata(struct device *dev)
					dev_err(dev,
					dev_err(dev,
						"Failed to get gpio flags, error: %d\n",
						"Failed to get gpio flags, error: %d\n",
						error);
						error);
				of_node_put(pp);
				return ERR_PTR(error);
				return ERR_PTR(error);
			}
			}
		} else {
		} else {
@@ -669,12 +670,14 @@ gpio_keys_get_devtree_pdata(struct device *dev)


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


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