lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [day] [month] [year] [list]
Message-ID: <20251124205649.3560456-1-richard@nod.at>
Date: Mon, 24 Nov 2025 21:56:49 +0100
From: Richard Weinberger <richard@....at>
To: linux-gpio@...r.kernel.org
Cc: linux-kernel@...r.kernel.org,
	brgl@...nel.org,
	linus.walleij@...aro.org,
	Richard Weinberger <richard@....at>
Subject: [PATCH] gpiolib: Warn if a single GPIO is expected but a list is found

Device tree properties such as reset-gpios can contain one or more
GPIOs but the vast majority of device drivers query only for a single
GPIO desc.
Add some aid to detect the case when someone defines multiple GPIOs
but a driver expected only one.
This would have saved me an hour today.

Signed-off-by: Richard Weinberger <richard@....at>
---
 drivers/gpio/gpiolib.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c
index cd8800ba5825f..d57d83cc4074e 100644
--- a/drivers/gpio/gpiolib.c
+++ b/drivers/gpio/gpiolib.c
@@ -4601,6 +4601,10 @@ static struct gpio_desc *gpiod_find_by_fwnode(struct fwnode_handle *fwnode,
 	const char *name = function_name_or_default(con_id);
 	struct gpio_desc *desc = ERR_PTR(-ENOENT);
 
+	if (gpiod_count(consumer, con_id) > 1)
+		dev_warn(consumer, "gpio property \"%s\" in %pfw has more than one elements, expected only one!\n",
+			 con_id, fwnode);
+
 	if (is_of_node(fwnode)) {
 		dev_dbg(consumer, "using DT '%pfw' for '%s' GPIO lookup\n", fwnode, name);
 		desc = of_find_gpio(to_of_node(fwnode), con_id, idx, lookupflags);
-- 
2.51.0


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ