rt2x00: call clk_get_rate only if we have a clock
Subsystems (2)
PATCH 1/1 rt2x00: call clk_get_rate only if we have a clock
If clk_get returns an error, rt2x00dev->clk is set to NULL. In contrast to the common clock framework provided clk_get_rate(), at least the ramips and bcm63xx legacy implementation of the clk API access the rate member of the clk struct without a NULL check. This results into a kernel panic if we do not have a (SoC) clock.
Call clk_get_rate only if we have a clock to fix the issues. This approach is similar to what is done in the kernel at various places. Usually clk_get_rate() is only called if clk_get_rate() doesn't return an error.
--- drivers/net/wireless/ralink/rt2x00/rt2800lib.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/net/wireless/ralink/rt2x00/rt2800lib.c +3 -0
@@ -2059,6 +2059,9 @@ static void rt2800_config_lna_gain(struct rt2x00_dev *rt2x00dev,static inline bool rt2800_clk_is_20mhz (struct rt2x00_dev *rt2x00dev) { +if (!rt2x00dev->clk) +return 0 ; +return clk_get_rate (rt2x00dev->clk) ==20000000 ; }
Signature · 1 line
2.7.4
08.07.2017 08:30, Mathias Kresin:
Quoted 22 lines
If
clk_getreturns an error,rt2x00dev->clkis set to NULL. In contrast to the common clock framework providedclk_get_rate(), at least the ramips and bcm63xx legacy implementation of the clk API access the rate member of the clk struct without a NULL check. This results into a kernel panic if we do not have a (SoC) clock.Call
clk_get_rateonly if we have a clock to fix the issues. This approach is similar to what is done in the kernel at various places. Usuallyclk_get_rate()is only called ifclk_get_rate()doesn't return an error.Signed-off-by Mathias Kresin <[email protected]>--- drivers/net/wireless/ralink/rt2x00/rt2800lib.c | 3 +++ 1 file changed, 3 insertions(+)drivers/net/wireless/ralink/rt2x00/rt2800lib.c +0
-0
drivers/net/wireless/ralink/rt2x00/rt2800lib.c static void rt2800_config_lna_gain(struct rt2x00_dev *rt2x00dev, · line 2067
Quoted 9 lines
drivers/net/wireless/ralink/rt2x00/rt2800lib.c +3
-0@@ -2059,6 +2059,9 @@ static void rt2800_config_lna_gain(struct rt2x00_dev *rt2x00dev,static inline bool rt2800_clk_is_20mhz (struct rt2x00_dev *rt2x00dev) { +if (!rt2x00dev->clk) +return 0 ; +return clk_get_rate (rt2x00dev->clk) ==20000000 ; }
Please disregard the patch. Send it to the wrong list.
Mathias