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>] [thread-next>] [day] [month] [year] [list]
Message-Id: <20210405031436.2465475-1-ilya.lipnitskiy@gmail.com>
Date:   Sun,  4 Apr 2021 20:14:36 -0700
From:   Ilya Lipnitskiy <ilya.lipnitskiy@...il.com>
To:     Rob Herring <robh+dt@...nel.org>,
        Frank Rowand <frowand.list@...il.com>,
        devicetree@...r.kernel.org, linux-kernel@...r.kernel.org
Cc:     Ilya Lipnitskiy <ilya.lipnitskiy@...il.com>,
        Saravana Kannan <saravanak@...gle.com>, stable@...r.kernel.org
Subject: [PATCH] of: property: do not create device links from *nr-gpios

[<vendor>,]nr-gpios property is used by some GPIO drivers[0] to indicate
the number of GPIOs present on a system, not define a GPIO. nr-gpios is
not configured by #gpio-cells and can't be parsed along with other
"*-gpios" properties.

scripts/dtc/checks.c also has a special case for nr-gpio{s}. However,
nr-gpio is not really special, so we only need to fix nr-gpios suffix
here.

[0]: nr-gpios is referenced in Documentation/devicetree/bindings/gpio:
 - gpio-adnp.txt
 - gpio-xgene-sb.txt
 - gpio-xlp.txt
 - snps,dw-apb-gpio.yaml

Fixes errors such as:
  OF: /palmbus@...000/gpio@600: could not find phandle

Call Trace:
  of_phandle_iterator_next+0x8c/0x16c
  __of_parse_phandle_with_args+0x38/0xb8
  of_parse_phandle_with_args+0x28/0x3c
  parse_suffix_prop_cells+0x80/0xac
  parse_gpios+0x20/0x2c
  of_link_to_suppliers+0x18c/0x288
  of_link_to_suppliers+0x1fc/0x288
  device_add+0x4e0/0x734
  of_platform_device_create_pdata+0xb8/0xfc
  of_platform_bus_create+0x170/0x214
  of_platform_populate+0x88/0xf4
  __dt_register_buses+0xbc/0xf0
  plat_of_setup+0x1c/0x34

Fixes: 7f00be96f125 ("of: property: Add device link support for interrupt-parent, dmas and -gpio(s)")
Signed-off-by: Ilya Lipnitskiy <ilya.lipnitskiy@...il.com>
Cc: Saravana Kannan <saravanak@...gle.com>
Cc: <stable@...r.kernel.org> # 5.5.x
---
 drivers/of/property.c | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/drivers/of/property.c b/drivers/of/property.c
index 2bb3158c9e43..24672c295603 100644
--- a/drivers/of/property.c
+++ b/drivers/of/property.c
@@ -1271,7 +1271,16 @@ DEFINE_SIMPLE_PROP(pinctrl8, "pinctrl-8", NULL)
 DEFINE_SIMPLE_PROP(remote_endpoint, "remote-endpoint", NULL)
 DEFINE_SUFFIX_PROP(regulators, "-supply", NULL)
 DEFINE_SUFFIX_PROP(gpio, "-gpio", "#gpio-cells")
-DEFINE_SUFFIX_PROP(gpios, "-gpios", "#gpio-cells")
+
+static struct device_node *parse_gpios(struct device_node *np,
+				       const char *prop_name, int index)
+{
+	if (!strcmp_suffix(prop_name, "nr-gpios"))
+		return NULL;
+
+	return parse_suffix_prop_cells(np, prop_name, index, "-gpios",
+				       "#gpio-cells");
+}
 
 static struct device_node *parse_iommu_maps(struct device_node *np,
 					    const char *prop_name, int index)
-- 
2.31.1

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ