Linux-RISC-V Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/1] drivers:rtc: fix return value check in mpfs_rtc_probe()
@ 2023-07-17 14:47 Yuanjun Gong
  2023-07-18 11:00 ` Conor Dooley
  0 siblings, 1 reply; 2+ messages in thread
From: Yuanjun Gong @ 2023-07-17 14:47 UTC (permalink / raw)
  To: Yuanjun Gong, Daire McNamara, Alessandro Zummo, Conor Dooley,
	linux-riscv

in mpfs_rtc_probe, devm_clk_get may fail, and its return value
should be checked before passing to clk_get_rate().

Signed-off-by: Yuanjun Gong <ruc_gongyuanjun@163.com>
---
 drivers/rtc/rtc-mpfs.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/drivers/rtc/rtc-mpfs.c b/drivers/rtc/rtc-mpfs.c
index 5b96a6d39210..c126df40c343 100644
--- a/drivers/rtc/rtc-mpfs.c
+++ b/drivers/rtc/rtc-mpfs.c
@@ -257,7 +257,11 @@ static int mpfs_rtc_probe(struct platform_device *pdev)
 	}
 
 	/* prescaler hardware adds 1 to reg value */
-	prescaler = clk_get_rate(devm_clk_get(&pdev->dev, "rtcref")) - 1;
+	clk = devm_clk_get(&pdev->dev, "rtcref");
+	if (IS_ERR(clk))
+		return PTR_ERR(clk);
+	prescaler = clk_get_rate(clk) - 1;
+
 	if (prescaler > MAX_PRESCALER_COUNT) {
 		dev_dbg(&pdev->dev, "invalid prescaler %lu\n", prescaler);
 		return -EINVAL;
-- 
2.17.1


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

^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2023-07-19  5:17 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-07-17 14:47 [PATCH 1/1] drivers:rtc: fix return value check in mpfs_rtc_probe() Yuanjun Gong
2023-07-18 11:00 ` Conor Dooley

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox