From: Mathias Kresin <dev@kresin.me>
To: sgruszka@redhat.com, helmut.schaa@googlemail.com, kvalo@codeaurora.org
Cc: linux-mips@linux-mips.org
Subject: [PATCH] rt2x00: call clk_get_rate only if we have a clock
Date: Sat, 8 Jul 2017 08:30:41 +0200 [thread overview]
Message-ID: <1499495441-4098-1-git-send-email-dev@kresin.me> (raw)
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.
Signed-off-by: Mathias Kresin <dev@kresin.me>
---
drivers/net/wireless/ralink/rt2x00/rt2800lib.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/drivers/net/wireless/ralink/rt2x00/rt2800lib.c b/drivers/net/wireless/ralink/rt2x00/rt2800lib.c
index d11c7b2..2a525b9 100644
--- a/drivers/net/wireless/ralink/rt2x00/rt2800lib.c
+++ b/drivers/net/wireless/ralink/rt2x00/rt2800lib.c
@@ -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;
}
--
2.7.4
next reply other threads:[~2017-07-08 6:30 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-07-08 6:30 Mathias Kresin [this message]
2017-07-08 7:24 ` [PATCH] rt2x00: call clk_get_rate only if we have a clock Mathias Kresin
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1499495441-4098-1-git-send-email-dev@kresin.me \
--to=dev@kresin.me \
--cc=helmut.schaa@googlemail.com \
--cc=kvalo@codeaurora.org \
--cc=linux-mips@linux-mips.org \
--cc=sgruszka@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox