Skip to contentSkip to conversation

pinctrl: rockchip: drop NULL check in rockchip_pinctrl_parse_groups()

PATCH New Sergey Shtylyov 1 participant 1 message Feb 23

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 pinctrl: rockchip: drop NULL check in rockchip_pinctrl_parse_groups()

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.

---
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/[email protected]/

 drivers/pinctrl/pinctrl-rockchip.c | 7 +------
 1 file changed, 1 insertion(+), 6 deletions(-)
drivers/pinctrl/pinctrl-rockchip.c +1 -6
index 816823403e97..8e195f951b9f 100644
@@ -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);
Signature · 1 line
2.53.0