[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <20190902222946.20548-1-yzhai003@ucr.edu>
Date: Mon, 2 Sep 2019 15:29:46 -0700
From: Yizhuo <yzhai003@....edu>
To: unlisted-recipients:; (no To-header on input)
Cc: csong@...ucr.edu, zhiyunq@...ucr.edu, Yizhuo <yzhai003@....edu>,
Daniel Lezcano <daniel.lezcano@...aro.org>,
Thomas Gleixner <tglx@...utronix.de>,
Nicolas Ferre <nicolas.ferre@...rochip.com>,
Alexandre Belloni <alexandre.belloni@...tlin.com>,
Ludovic Desroches <ludovic.desroches@...rochip.com>,
linux-kernel@...r.kernel.org, linux-arm-kernel@...ts.infradead.org
Subject: [PATCH] clocksource: atmel-st: Variable sr in at91rm9200_timer_interrupt() could be uninitialized
Inside function at91rm9200_timer_interrupt(), variable sr could
be uninitialized if regmap_read() fails. However, sr is used
to decide the control flow later in the if statement, which is
potentially unsafe. We could check the return value of
regmap_read() and print an error here.
Signed-off-by: Yizhuo <yzhai003@....edu>
---
drivers/clocksource/timer-atmel-st.c | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/drivers/clocksource/timer-atmel-st.c b/drivers/clocksource/timer-atmel-st.c
index ab0aabfae5f0..061a3f27847e 100644
--- a/drivers/clocksource/timer-atmel-st.c
+++ b/drivers/clocksource/timer-atmel-st.c
@@ -48,8 +48,14 @@ static inline unsigned long read_CRTR(void)
static irqreturn_t at91rm9200_timer_interrupt(int irq, void *dev_id)
{
u32 sr;
+ int ret;
+
+ ret = regmap_read(regmap_st, AT91_ST_SR, &sr);
+ if (ret) {
+ pr_err("Fail to read AT91_ST_SR.\n");
+ return ret;
+ }
- regmap_read(regmap_st, AT91_ST_SR, &sr);
sr &= irqmask;
/*
--
2.17.1
Powered by blists - more mailing lists