Skip to contentSkip to conversation

mmc: sdhci-brcmstb: Initialize base_clk to NULL in sdhci_brcmstb_probe()

PATCH In review Nathan Chancellor 4 participants 4 messages Jun 8, 2022 – Jun 15, 2022

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

PATCH 1/1 mmc: sdhci-brcmstb: Initialize base_clk to NULL in sdhci_brcmstb_probe()

Clang warns a few times along the lines of:

drivers/mmc/host/sdhci-brcmstb.c:302:6: warning: variable 'base_clk' is used uninitialized whenever 'if' condition is true [-Wsometimes-uninitialized]

          if (res)
              ^~~
  drivers/mmc/host/sdhci-brcmstb.c:376:24: note: uninitialized use occurs here
          clk_disable_unprepare(base_clk);
                                ^~~~~~~~

base_clk is used in the error path before it is initialized. Initialize it to NULL, as clk_disable_unprepare() calls clk_disable() and clk_unprepare(), which both handle NULL pointers gracefully.

Fixes 2cecaac1b21c ("mmc: sdhci-brcmstb: Add ability to increase max clock rate for 72116b0")
---
 drivers/mmc/host/sdhci-brcmstb.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/mmc/host/sdhci-brcmstb.c +1 -1
index f8dff8537920..28e9cf995c41 100644
@@ -256,7 +256,7 @@ static int sdhci_brcmstb_probe(struct platform_device *pdev)
 	struct sdhci_host *host;
 	struct resource *iomem;
 	struct clk *clk;
-	struct clk *base_clk;
+	struct clk *base_clk = NULL;
 	int res;
 
 	match = of_match_node(sdhci_brcm_of_match, pdev->dev.of_node);

base-commit: 10980053142d8a3e86eb4d3014574424b42b7a45

Signature · 1 line
2.36.1
Acked-by on v1 1/1
#1 lore raw
Quoted 9 lines · Nathan Chancellor

Clang warns a few times along the lines of:

   drivers/mmc/host/sdhci-brcmstb.c:302:6: warning: variable 'base_clk' is used uninitialized whenever 'if' condition is true [-Wsometimes-uninitialized]
           if (res)
               ^~~
   drivers/mmc/host/sdhci-brcmstb.c:376:24: note: uninitialized use occurs here
           clk_disable_unprepare(base_clk);
                                 ^~~~~~~~
Quoted 8 lines

base_clk is used in the error path before it is initialized. Initialize it to NULL, as clk_disable_unprepare() calls clk_disable() and clk_unprepare(), which both handle NULL pointers gracefully.

Fixes 2cecaac1b21c ("mmc: sdhci-brcmstb: Add ability to increase max clock rate for 72116b0")
Signature · 1 line
Florian
maintainer Acked-by on v1 1/1
#2 lore raw
In reply to Nathan Chancellor
Quoted 9 lines · Nathan Chancellor

Clang warns a few times along the lines of:

drivers/mmc/host/sdhci-brcmstb.c:302:6: warning: variable 'base_clk' is used uninitialized whenever 'if' condition is true [-Wsometimes-uninitialized]

          if (res)
              ^~~
  drivers/mmc/host/sdhci-brcmstb.c:376:24: note: uninitialized use occurs here
          clk_disable_unprepare(base_clk);
                                ^~~~~~~~
Quoted 8 lines

base_clk is used in the error path before it is initialized. Initialize it to NULL, as clk_disable_unprepare() calls clk_disable() and clk_unprepare(), which both handle NULL pointers gracefully.

Fixes 2cecaac1b21c ("mmc: sdhci-brcmstb: Add ability to increase max clock rate for 72116b0")
Quoted 19 lines
---
 drivers/mmc/host/sdhci-brcmstb.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/mmc/host/sdhci-brcmstb.c +1 -1
index f8dff8537920..28e9cf995c41 100644
@@ -256,7 +256,7 @@ static int sdhci_brcmstb_probe(struct platform_device *pdev)
 	struct sdhci_host *host;
 	struct resource *iomem;
 	struct clk *clk;
-	struct clk *base_clk;
+	struct clk *base_clk = NULL;
 	int res;
 
 	match = of_match_node(sdhci_brcm_of_match, pdev->dev.of_node);

base-commit: 10980053142d8a3e86eb4d3014574424b42b7a45

#3 lore raw
In reply to Nathan Chancellor
Quoted 10 lines · Nathan Chancellor

Clang warns a few times along the lines of:

drivers/mmc/host/sdhci-brcmstb.c:302:6: warning: variable 'base_clk' is used uninitialized whenever 'if' condition is true [-Wsometimes-uninitialized]

          if (res)
              ^~~
  drivers/mmc/host/sdhci-brcmstb.c:376:24: note: uninitialized use occurs here
          clk_disable_unprepare(base_clk);
                                ^~~~~~~~
Quoted 8 lines

base_clk is used in the error path before it is initialized. Initialize it to NULL, as clk_disable_unprepare() calls clk_disable() and clk_unprepare(), which both handle NULL pointers gracefully.

Fixes 2cecaac1b21c ("mmc: sdhci-brcmstb: Add ability to increase max clock rate for 72116b0")

Applied for next, thanks!

Kind regards
Uffe

Quoted 22 lines
---
 drivers/mmc/host/sdhci-brcmstb.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/mmc/host/sdhci-brcmstb.c +1 -1
index f8dff8537920..28e9cf995c41 100644
@@ -256,7 +256,7 @@ static int sdhci_brcmstb_probe(struct platform_device *pdev)
        struct sdhci_host *host;
        struct resource *iomem;
        struct clk *clk;
-       struct clk *base_clk;
+       struct clk *base_clk = NULL;
        int res;
 
        match = of_match_node(sdhci_brcm_of_match, pdev->dev.of_node);

base-commit: 10980053142d8a3e86eb4d3014574424b42b7a45 --
2.36.1