Skip to contentSkip to conversation

clk: st: avoid uninitialized variable use

PATCH Applied Arnd Bergmann 3 participants 3 messages Nov 12, 2015 – Nov 20, 2015 Common clk

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 clk: st: avoid uninitialized variable use

quadfs_pll_fs660c32_round_rate prints a few structure members that are never initialized, and also doesn't print the only one it cares about. We get a gcc warning about the ones that are printed:

clk/st/clkgen-fsyn.c:560:93: warning: 'params.sdiv' may be used uninitialized in this function clk/st/clkgen-fsyn.c:560:93: warning: 'params.mdiv' may be used uninitialized in this function clk/st/clkgen-fsyn.c:560:93: warning: 'params.pe' may be used uninitialized in this function clk/st/clkgen-fsyn.c:560:93: warning: 'params.nsdiv' may be used uninitialized in this function

This changes the code to no longer print uninitialized data, and for good measure it also prints the ndiv member that is being set.

Fixes 5f7aa9071e93 ("clk: st: Support for QUADFS inside ClockGenB/C/D/E/F")
drivers/clk/st/clkgen-fsyn.c +9 -8
index 576cd0354d48..ccb324d97160 100644
@@ -549,19 +549,20 @@ static int clk_fs660c32_vco_get_params(unsigned long input,
 	return 0;
 }
 
-static long quadfs_pll_fs660c32_round_rate(struct clk_hw *hw, unsigned long rate
-		, unsigned long *prate)
+static long quadfs_pll_fs660c32_round_rate(struct clk_hw *hw,
+					   unsigned long rate,
+					   unsigned long *prate)
 {
 	struct stm_fs params;
 
-	if (!clk_fs660c32_vco_get_params(*prate, rate, &params))
-		clk_fs660c32_vco_get_rate(*prate, &params, &rate);
+	if (clk_fs660c32_vco_get_params(*prate, rate, &params))
+		return rate;
 
-	pr_debug("%s: %s new rate %ld [sdiv=0x%x,md=0x%x,pe=0x%x,nsdiv3=%u]\n",
+	clk_fs660c32_vco_get_rate(*prate, &params, &rate);
+
+	pr_debug("%s: %s new rate %ld [ndiv=%u]\n",
 		 __func__, clk_hw_get_name(hw),
-		 rate, (unsigned int)params.sdiv,
-		 (unsigned int)params.mdiv,
-		 (unsigned int)params.pe, (unsigned int)params.nsdiv);
+		 rate, (unsigned int)params.ndiv);
 
 	return rate;
 }
Acked-by on v1 1/1
#1 lore raw
Quoted 42 lines · Arnd Bergmann

quadfs_pll_fs660c32_round_rate prints a few structure members that are never initialized, and also doesn't print the only one it cares about. We get a gcc warning about the ones that are printed:

clk/st/clkgen-fsyn.c:560:93: warning: 'params.sdiv' may be used uninitialized in this function clk/st/clkgen-fsyn.c:560:93: warning: 'params.mdiv' may be used uninitialized in this function clk/st/clkgen-fsyn.c:560:93: warning: 'params.pe' may be used uninitialized in this function clk/st/clkgen-fsyn.c:560:93: warning: 'params.nsdiv' may be used uninitialized in this function

This changes the code to no longer print uninitialized data, and for good measure it also prints the ndiv member that is being set.

Fixes 5f7aa9071e93 ("clk: st: Support for QUADFS inside ClockGenB/C/D/E/F")
drivers/clk/st/clkgen-fsyn.c +6 -5
index 576cd0354d48..ccb324d97160 100644
@@ -549,19 +549,20 @@ static int clk_fs660c32_vco_get_params(unsigned long input,
        return 0;
 }
 
-static long quadfs_pll_fs660c32_round_rate(struct clk_hw *hw, unsigned long rate
-               , unsigned long *prate)
+static long quadfs_pll_fs660c32_round_rate(struct clk_hw *hw,
+                                          unsigned long rate,
+                                          unsigned long *prate)
 {
        struct stm_fs params;
 
-       if (!clk_fs660c32_vco_get_params(*prate, rate, &params))
-               clk_fs660c32_vco_get_rate(*prate, &params, &rate);
+       if (clk_fs660c32_vco_get_params(*prate, rate, &params))
+               return rate;
 
-       pr_debug("%s: %s new rate %ld [sdiv=0x%x,md=0x%x,pe=0x%x,nsdiv3=%u]\n",
+       clk_fs660c32_vco_get_rate(*prate, &params, &rate);

drivers/clk/st/clkgen-fsyn.c static int clk_fs660c32_vco_get_params(unsigned long input, · line 568

Quoted 10 lines
drivers/clk/st/clkgen-fsyn.c +3 -3
+
+       pr_debug("%s: %s new rate %ld [ndiv=%u]\n",
                 __func__, clk_hw_get_name(hw),
-                rate, (unsigned int)params.sdiv,
-                (unsigned int)params.mdiv,
-                (unsigned int)params.pe, (unsigned int)params.nsdiv);
+                rate, (unsigned int)params.ndiv);
 
        return rate;
 }

Thanks

Applied
#2 lore raw
In reply to Arnd Bergmann
Quoted 19 lines · Arnd Bergmann

quadfs_pll_fs660c32_round_rate prints a few structure members that are never initialized, and also doesn't print the only one it cares about. We get a gcc warning about the ones that are printed:

clk/st/clkgen-fsyn.c:560:93: warning: 'params.sdiv' may be used uninitialized in this function clk/st/clkgen-fsyn.c:560:93: warning: 'params.mdiv' may be used uninitialized in this function clk/st/clkgen-fsyn.c:560:93: warning: 'params.pe' may be used uninitialized in this function clk/st/clkgen-fsyn.c:560:93: warning: 'params.nsdiv' may be used uninitialized in this function

This changes the code to no longer print uninitialized data, and for good measure it also prints the ndiv member that is being set.

Fixes 5f7aa9071e93 ("clk: st: Support for QUADFS inside ClockGenB/C/D/E/F")
drivers/clk/st/clkgen-fsyn.c +0 -0
index 576cd0354d48..ccb324d97160 100644

drivers/clk/st/clkgen-fsyn.c

Quoted 1 line
drivers/clk/st/clkgen-fsyn.c +0 -1
--- a/drivers/clk/st/clkgen-fsyn.c

Applied to clk-next

Signature · 2 lines
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum,
a Linux Foundation Collaborative Project