Skip to contentSkip to conversation

net: rswitch: Fix error detection

PATCH In review Andrew Goodbody 2 participants 2 messages Aug 6, 2025 Network drivers

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 net: rswitch: Fix error detection

In rswitch_probe the error detection after the call to devm_clk_get is very wrong. It checks the value of ret which is uninitialised at that point. Instead it should be using the macros for including errors into pointers.

This issue was found by Smatch.

---
 drivers/net/rswitch.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/net/rswitch.c +3 -1
index 62d3f39f071..f27587ac8bd 100644
@@ -1110,8 +1110,10 @@ static int rswitch_probe(struct udevice *dev)
 		return -EINVAL;
 
 	priv->rsw_clk = devm_clk_get(dev, NULL);
-	if (ret)
+	if (IS_ERR(priv->rsw_clk)) {
+		ret = PTR_ERR(priv->rsw_clk);
 		goto err_map;
+	}
 
 	ret = clk_prepare_enable(priv->rsw_clk);
 	if (ret)

---
base-commit: 007610da2cca405ea7739fc120d90085be4b6ac2
change-id: 20250806-net_rswitch-8aad613047cf

Best regards,

Signature · 1 line
Andrew Goodbody <[email protected]>
Reviewed-by on v1 1/1
#1 lore raw
Quoted 8 lines · Andrew Goodbody

In rswitch_probe the error detection after the call to devm_clk_get is very wrong. It checks the value of ret which is uninitialised at that point. Instead it should be using the macros for including errors into pointers.

This issue was found by Smatch.

Thanks !