From: Krzysztof Kozlowski <k.kozlowski@samsung.com>
To: Tero Kristo <t-kristo@ti.com>,
Mike Turquette <mturquette@linaro.org>,
Stephen Boyd <sboyd@codeaurora.org>,
linux-omap@vger.kernel.org, linux-clk@vger.kernel.org,
linux-kernel@vger.kernel.org
Cc: Krzysztof Kozlowski <k.kozlowski@samsung.com>
Subject: [RFT PATCH 3/8] clk: ti: clk-3xxx: Prevent possible ERR_PTR dereference
Date: Wed, 13 May 2015 15:54:42 +0900 [thread overview]
Message-ID: <1431500087-2275-4-git-send-email-k.kozlowski@samsung.com> (raw)
In-Reply-To: <1431500087-2275-1-git-send-email-k.kozlowski@samsung.com>
Provide a wrapper to prevent possible ERR_PTR dereference by
clk_get_rate().
The return value of clk_get_sys() was immediately used in
clk_get_rate(). The first one may return ERR_PTR and the latter only
checks if supplied argument is non-NULL.
Signed-off-by: Krzysztof Kozlowski <k.kozlowski@samsung.com>
---
drivers/clk/ti/clk-3xxx.c | 18 ++++++++++++++----
1 file changed, 14 insertions(+), 4 deletions(-)
diff --git a/drivers/clk/ti/clk-3xxx.c b/drivers/clk/ti/clk-3xxx.c
index 757636d166cf..1db3afff34fb 100644
--- a/drivers/clk/ti/clk-3xxx.c
+++ b/drivers/clk/ti/clk-3xxx.c
@@ -324,6 +324,16 @@ enum {
OMAP3_SOC_OMAP3630,
};
+static unsigned long __init omap3xxx_clk_get_rate(const char *clk_name)
+{
+ struct clk *clk = clk_get_sys(NULL, clk_name);
+
+ if (IS_ERR(clk))
+ return 0;
+
+ return clk_get_rate(clk);
+}
+
static int __init omap3xxx_dt_clk_init(int soc_type)
{
if (soc_type == OMAP3_SOC_AM35XX || soc_type == OMAP3_SOC_OMAP3630 ||
@@ -359,10 +369,10 @@ static int __init omap3xxx_dt_clk_init(int soc_type)
ARRAY_SIZE(enable_init_clks));
pr_info("Clocking rate (Crystal/Core/MPU): %ld.%01ld/%ld/%ld MHz\n",
- (clk_get_rate(clk_get_sys(NULL, "osc_sys_ck")) / 1000000),
- (clk_get_rate(clk_get_sys(NULL, "osc_sys_ck")) / 100000) % 10,
- (clk_get_rate(clk_get_sys(NULL, "core_ck")) / 1000000),
- (clk_get_rate(clk_get_sys(NULL, "arm_fck")) / 1000000));
+ (omap3xxx_clk_get_rate("osc_sys_ck") / 1000000),
+ (omap3xxx_clk_get_rate("osc_sys_ck") / 100000) % 10,
+ (omap3xxx_clk_get_rate("core_ck") / 1000000),
+ (omap3xxx_clk_get_rate("arm_fck") / 1000000));
if (soc_type != OMAP3_SOC_OMAP3430_ES1)
omap3_clk_lock_dpll5();
--
1.9.1
next prev parent reply other threads:[~2015-05-13 6:55 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-05-13 6:54 [RFT PATCH 0/8] clk: ti: Fix possible ERR_PTR dereferences from clk_get_sys Krzysztof Kozlowski
2015-05-13 6:54 ` [RFT PATCH 1/8] clk: ti: dra7-atl-clock: Fix possible ERR_PTR dereference Krzysztof Kozlowski
2015-05-14 22:31 ` Stephen Boyd
2015-05-13 6:54 ` [RFT PATCH 2/8] clk: ti: clk-2xxx: Prevent " Krzysztof Kozlowski
2015-05-13 6:54 ` Krzysztof Kozlowski [this message]
2015-05-13 6:54 ` [RFT PATCH 4/8] clk: ti: clk-33xx: " Krzysztof Kozlowski
2015-05-13 6:54 ` [RFT PATCH 5/8] clk: ti: clk-43xx: " Krzysztof Kozlowski
2015-05-13 6:54 ` [RFT PATCH 6/8] " Krzysztof Kozlowski
2015-05-13 6:54 ` [RFT PATCH 7/8] clk: ti: clk-54xx: " Krzysztof Kozlowski
2015-05-13 6:54 ` [RFT PATCH 8/8] clk: ti: clk-7xx: " Krzysztof Kozlowski
2015-05-13 7:07 ` [RFT PATCH 0/8] clk: ti: Fix possible ERR_PTR dereferences from clk_get_sys Tero Kristo
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=1431500087-2275-4-git-send-email-k.kozlowski@samsung.com \
--to=k.kozlowski@samsung.com \
--cc=linux-clk@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-omap@vger.kernel.org \
--cc=mturquette@linaro.org \
--cc=sboyd@codeaurora.org \
--cc=t-kristo@ti.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
all inboxes | Powered by JetHome®