Skip to contentSkip to conversation

clk: s2mps11: Check of_clk_add_hw_provider() result

PATCH In review Aleksandr Aprelkov 3 participants 3 messages Apr 1, 2024

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

PATCH 1/1 clk: s2mps11: Check of_clk_add_hw_provider() result

There is no check if error occurs in clock provider registration.

Found by Linux Verification Center (linuxtesting.org) with SVACE.

Fixes b228fad50c00 ("clk: s2mps11: Migrate to clk_hw based OF and registration APIs")
---
 drivers/clk/clk-s2mps11.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/clk/clk-s2mps11.c +3 -1
index 38c456540d1b..f9ce413b6c02 100644
@@ -187,8 +187,10 @@ static int s2mps11_clk_probe(struct platform_device *pdev)
 	}
 
 	clk_data->num = S2MPS11_CLKS_NUM;
-	of_clk_add_hw_provider(s2mps11_clks->clk_np, of_clk_hw_onecell_get,
+	ret = of_clk_add_hw_provider(s2mps11_clks->clk_np, of_clk_hw_onecell_get,
 			       clk_data);
+	if (ret < 0)
+		goto err_reg;
 
 	platform_set_drvdata(pdev, s2mps11_clks);
 
Signature · 1 line
2.34.1
#1 lore raw

Le 01/04/2024 à 12:38, Aleksandr Aprelkov a écrit :

Quoted 15 lines

There is no check if error occurs in clock provider registration.

Found by Linux Verification Center (linuxtesting.org) with SVACE.

Fixes b228fad50c00 ("clk: s2mps11: Migrate to clk_hw based OF and registration APIs")
---
  drivers/clk/clk-s2mps11.c | 4 +++-
  1 file changed, 3 insertions(+), 1 deletion(-)
drivers/clk/clk-s2mps11.c +0 -0
index 38c456540d1b..f9ce413b6c02 100644

drivers/clk/clk-s2mps11.c static int s2mps11_clk_probe(struct platform_device *pdev) · line 191

Quoted 6 lines
drivers/clk/clk-s2mps11.c +1 -1
@@ -187,8 +187,10 @@ static int s2mps11_clk_probe(struct platform_device *pdev)
  	}
 
  	clk_data->num = S2MPS11_CLKS_NUM;
-	of_clk_add_hw_provider(s2mps11_clks->clk_np, of_clk_hw_onecell_get,
+	ret = of_clk_add_hw_provider(s2mps11_clks->clk_np, of_clk_hw_onecell_get,
  			       clk_data);

Hi,

Nit: "clk_data);" is wrongly aligned now.

CJ

Quoted 5 lines
drivers/clk/clk-s2mps11.c +2 -0
+	if (ret < 0)
+		goto err_reg;
 
  	platform_set_drvdata(pdev, s2mps11_clks);
 
#2 lore raw
In reply to Aleksandr Aprelkov
Quoted 1 line · Aleksandr Aprelkov

There is no check if error occurs in clock provider registration.

No, instead explain why there should be a check.

Quoted 14 lines

Found by Linux Verification Center (linuxtesting.org) with SVACE.

Fixes b228fad50c00 ("clk: s2mps11: Migrate to clk_hw based OF and registration APIs")
---
 drivers/clk/clk-s2mps11.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/clk/clk-s2mps11.c +0 -0
index 38c456540d1b..f9ce413b6c02 100644

drivers/clk/clk-s2mps11.c static int s2mps11_clk_probe(struct platform_device *pdev) · line 193

Quoted 8 lines
drivers/clk/clk-s2mps11.c +3 -1
@@ -187,8 +187,10 @@ static int s2mps11_clk_probe(struct platform_device *pdev)
 	}
 
 	clk_data->num = S2MPS11_CLKS_NUM;
-	of_clk_add_hw_provider(s2mps11_clks->clk_np, of_clk_hw_onecell_get,
+	ret = of_clk_add_hw_provider(s2mps11_clks->clk_np, of_clk_hw_onecell_get,
 			       clk_data);
+	if (ret < 0)
+		goto err_reg;

I really do not understand why you are doing this. This SVACE in the past was creating really fake reports and we were complaining multiple times that you should fix your tool.

NAK for such explanation.

Best regards,
Krzysztof