[PATCH v2] regulator: of: Drop dead code in of_get_regulation_constraints()
From: Sergey Shtylyov
Date: Mon Jun 08 2026 - 13:30:24 EST
From: Karina Yankevich <k.yankevich@xxxxxx>
In of_get_regulation_constraints(), the variable suspend_state is either
assigned &constraints->state_* pointer (that apparently can never be NULL)
in the *switch* statement at the start of the *for* loop or that loop just
skips the current iteration using the *continue* statement; thus the 2nd
(after the of_get_child_by_name() call) *if* statement's condition would
never be true. Hence we can drop the dead code...
Found by Linux Verification Center (linuxtesting.org) with the Svace static
analysis tool.
[Sergey: rewrote the subject/description]
Signed-off-by: Karina Yankevich <k.yankevich@xxxxxx>
Signed-off-by: Sergey Shtylyov <s.shtylyov@xxxxxxxxxxxx>
---
The patch is against the for-next branch of Mark Brown's regulator.git repo...
Changes in version 2:
- rewrote the patch subject/description;
- refreshed the patch.
Here's the link to version 1:
https://lore.kernel.org/all/20231218095707.2625407-1-k.yankevich@xxxxxx/
drivers/regulator/of_regulator.c | 4 ----
1 file changed, 4 deletions(-)
diff --git a/drivers/regulator/of_regulator.c b/drivers/regulator/of_regulator.c
index c0cc6cc0afd8..d873b7e2dd90 100644
--- a/drivers/regulator/of_regulator.c
+++ b/drivers/regulator/of_regulator.c
@@ -278,10 +278,6 @@ static int of_get_regulation_constraints(struct device *dev,
suspend_np = of_get_child_by_name(np, regulator_states[i]);
if (!suspend_np)
continue;
- if (!suspend_state) {
- of_node_put(suspend_np);
- continue;
- }
if (!of_property_read_u32(suspend_np, "regulator-mode",
&pval)) {
--
2.54.0