linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: Sasha Levin <sashal@kernel.org>
To: linux-kernel@vger.kernel.org, stable@vger.kernel.org
Cc: Maxime Ripard <maxime.ripard@bootlin.com>,
	Sasha Levin <sashal@kernel.org>, Chen-Yu Tsai <wens@csie.org>,
	Daniel Lezcano <daniel.lezcano@linaro.org>,
	linux-arm-kernel@lists.infradead.org
Subject: [PATCH AUTOSEL 4.19 214/671] clocksource/drivers/sun5i: Fail gracefully when clock rate is unavailable
Date: Thu, 16 Jan 2020 11:52:03 -0500	[thread overview]
Message-ID: <20200116165940.10720-97-sashal@kernel.org> (raw)
In-Reply-To: <20200116165940.10720-1-sashal@kernel.org>

From: Chen-Yu Tsai <wens@csie.org>

[ Upstream commit e7e7e0d7beafebd11b0c065cd5fbc1e5759c5aab ]

If the clock tree is not fully populated when the timer-sun5i init code
is called, attempts to get the clock rate for the timer would fail and
return 0.

Make the init code for both clock events and clocksource check the
returned clock rate and fail gracefully if the result is 0, instead of
causing a divide by 0 exception later on.

Fixes: 4a59058f0b09 ("clocksource/drivers/sun5i: Refactor the current code")
Signed-off-by: Chen-Yu Tsai <wens@csie.org>
Acked-by: Maxime Ripard <maxime.ripard@bootlin.com>
Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 drivers/clocksource/timer-sun5i.c | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/drivers/clocksource/timer-sun5i.c b/drivers/clocksource/timer-sun5i.c
index 3b56ea3f52af..552c5254390c 100644
--- a/drivers/clocksource/timer-sun5i.c
+++ b/drivers/clocksource/timer-sun5i.c
@@ -202,6 +202,11 @@ static int __init sun5i_setup_clocksource(struct device_node *node,
 	}
 
 	rate = clk_get_rate(clk);
+	if (!rate) {
+		pr_err("Couldn't get parent clock rate\n");
+		ret = -EINVAL;
+		goto err_disable_clk;
+	}
 
 	cs->timer.base = base;
 	cs->timer.clk = clk;
@@ -275,6 +280,11 @@ static int __init sun5i_setup_clockevent(struct device_node *node, void __iomem
 	}
 
 	rate = clk_get_rate(clk);
+	if (!rate) {
+		pr_err("Couldn't get parent clock rate\n");
+		ret = -EINVAL;
+		goto err_disable_clk;
+	}
 
 	ce->timer.base = base;
 	ce->timer.ticks_per_jiffy = DIV_ROUND_UP(rate, HZ);
-- 
2.20.1


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

  parent reply	other threads:[~2020-01-16 17:12 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-01-16 16:50 [PATCH AUTOSEL 4.19 118/671] media: s5p-jpeg: Correct step and max values for V4L2_CID_JPEG_RESTART_INTERVAL Sasha Levin
2020-01-16 16:50 ` [PATCH AUTOSEL 4.19 122/671] ASoC: imx-sgtl5000: put of nodes if finding codec fails Sasha Levin
2020-01-16 16:50 ` [PATCH AUTOSEL 4.19 130/671] ARM: dts: sun8i-a23-a33: Move NAND controller device node to sort by address Sasha Levin
2020-01-16 16:50 ` [PATCH AUTOSEL 4.19 131/671] clk: sunxi-ng: sun8i-a23: Enable PLL-MIPI LDOs when ungating it Sasha Levin
2020-01-16 16:50 ` [PATCH AUTOSEL 4.19 135/671] arm64: dts: allwinner: h6: Move GIC device node fix base address ordering Sasha Levin
2020-01-16 16:50 ` [PATCH AUTOSEL 4.19 147/671] ARM: dts: lpc32xx: add required clocks property to keypad device node Sasha Levin
2020-01-16 16:50 ` [PATCH AUTOSEL 4.19 148/671] ARM: dts: lpc32xx: reparent keypad controller to SIC1 Sasha Levin
2020-01-16 16:50 ` [PATCH AUTOSEL 4.19 149/671] ARM: dts: lpc32xx: fix ARM PrimeCell LCD controller variant Sasha Levin
2020-01-16 16:50 ` [PATCH AUTOSEL 4.19 150/671] ARM: dts: lpc32xx: fix ARM PrimeCell LCD controller clocks property Sasha Levin
2020-01-16 16:51 ` [PATCH AUTOSEL 4.19 151/671] ARM: dts: lpc32xx: phy3250: fix SD card regulator voltage Sasha Levin
2020-01-16 16:51 ` [PATCH AUTOSEL 4.19 157/671] thermal: mediatek: fix register index error Sasha Levin
2020-01-16 16:51 ` [PATCH AUTOSEL 4.19 187/671] mt76: usb: fix possible memory leak in mt76u_buf_free Sasha Levin
2020-01-16 16:52 ` [PATCH AUTOSEL 4.19 213/671] perf, pt, coresight: Fix address filters for vmas with non-zero offset Sasha Levin
2020-01-16 16:52 ` Sasha Levin [this message]
2020-01-16 16:52 ` [PATCH AUTOSEL 4.19 215/671] clocksource/drivers/exynos_mct: Fix error path in timer resources initialization Sasha Levin
2020-01-16 16:52 ` [PATCH AUTOSEL 4.19 218/671] mmc: sdhci-brcmstb: handle mmc_of_parse() errors during probe Sasha Levin
2020-01-16 16:52 ` [PATCH AUTOSEL 4.19 220/671] ARM: 8847/1: pm: fix HYP/SVC mode mismatch when MCPM is used Sasha Levin
2020-01-16 16:52 ` [PATCH AUTOSEL 4.19 221/671] ARM: 8848/1: virt: Align GIC version check with arm64 counterpart Sasha Levin
2020-01-16 16:52 ` [PATCH AUTOSEL 4.19 222/671] ARM: 8849/1: NOMMU: Fix encodings for PMSAv8's PRBAR4/PRLAR4 Sasha Levin
2020-01-16 16:52 ` [PATCH AUTOSEL 4.19 228/671] hwrng: bcm2835 - fix probe as platform device Sasha Levin
2020-01-16 16:52 ` [PATCH AUTOSEL 4.19 247/671] soc: amlogic: gx-socinfo: Add mask for each SoC packages Sasha Levin
2020-01-16 16:52 ` [PATCH AUTOSEL 4.19 257/671] ARM: dts: sun8i: a33: Reintroduce default pinctrl muxing Sasha Levin
2020-01-16 16:52 ` [PATCH AUTOSEL 4.19 258/671] arm64: dts: allwinner: a64: Add missing PIO clocks Sasha Levin
2020-01-16 16:52 ` [PATCH AUTOSEL 4.19 259/671] ARM: dts: sun9i: optimus: Fix fixed-regulators Sasha Levin
2020-01-16 16:52 ` [PATCH AUTOSEL 4.19 261/671] ARM: OMAP2+: Fix potentially uninitialized return value for _setup_reset() Sasha Levin

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=20200116165940.10720-97-sashal@kernel.org \
    --to=sashal@kernel.org \
    --cc=daniel.lezcano@linaro.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=maxime.ripard@bootlin.com \
    --cc=stable@vger.kernel.org \
    --cc=wens@csie.org \
    /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;
as well as URLs for NNTP newsgroup(s).