[PATCH] pinctrl: rockchip: drop NULL check in rockchip_pinctrl_parse_groups()
Sergey Shtylyov
s.shtylyov at auroraos.dev
Mon Feb 23 12:14:10 PST 2026
In rockchip_pinctrl_parse_groups(), even if the "rockchip,pins" property
is absent in the DT node it parses and so of_get_property() returns NULL,
the phandle pointer is checked for NULL amidst the *for* loop after the
list pointer (from which it's copied) being already advanced (and even
dereferenced), so it can't be NULL anymore (unless we have a wraparound);
thus the NULL check seems pointless, and when we drop it, the variable
phandle itself becomes pretty useless -- let's get rid of it as well...
Found by Linux Verification Center (linuxtesting.org) with the Svace static
analysis tool.
Signed-off-by: Sergey Shtylyov <s.shtylyov at auroraos.dev>
---
The patch is against the for-next branch of Linus W.'s linux-pinctrl.git repo.
Here's the prior patch adding the NULL check where it really belonged but
eventually ignored by Linus:
https://lore.kernel.org/all/179c9e8c-8760-41e6-aad7-7a128df60984@omp.ru/
drivers/pinctrl/pinctrl-rockchip.c | 7 +------
1 file changed, 1 insertion(+), 6 deletions(-)
diff --git a/drivers/pinctrl/pinctrl-rockchip.c b/drivers/pinctrl/pinctrl-rockchip.c
index 816823403e97..8e195f951b9f 100644
--- a/drivers/pinctrl/pinctrl-rockchip.c
+++ b/drivers/pinctrl/pinctrl-rockchip.c
@@ -3863,7 +3863,6 @@ static int rockchip_pinctrl_parse_groups(struct device_node *np,
return -ENOMEM;
for (i = 0, j = 0; i < size; i += 4, j++) {
- const __be32 *phandle;
struct device_node *np_config;
num = be32_to_cpu(*list++);
@@ -3874,11 +3873,7 @@ static int rockchip_pinctrl_parse_groups(struct device_node *np,
grp->pins[j] = bank->pin_base + be32_to_cpu(*list++);
grp->data[j].func = be32_to_cpu(*list++);
- phandle = list++;
- if (!phandle)
- return -EINVAL;
-
- np_config = of_find_node_by_phandle(be32_to_cpup(phandle));
+ np_config = of_find_node_by_phandle(be32_to_cpup(list++));
ret = pinconf_generic_parse_dt_config(np_config, NULL,
&grp->data[j].configs, &grp->data[j].nconfigs);
of_node_put(np_config);
--
2.53.0
More information about the linux-arm-kernel
mailing list