rtc: check if __rtc_read_time was successful
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2071847
Tested: This is one of a series of patch sets to enable Arm SystemReady IR
support in the kernel for compliant platforms. This set updates the
RTC drivers as needed in drivers/rtc. This set has been tested via
simple boot tests, and of course the CI loop.
commit 915593a7a663b2ad08b895a5f3ba8b19d89d4ebf
Author: Tom Rix <trix@redhat.com>
Date: Sat Mar 26 12:42:36 2022 -0700
rtc: check if __rtc_read_time was successful
Clang static analysis reports this issue
interface.c:810:8: warning: Passed-by-value struct
argument contains uninitialized data
now = rtc_tm_to_ktime(tm);
^~~~~~~~~~~~~~~~~~~
tm is set by a successful call to __rtc_read_time()
but its return status is not checked. Check if
it was successful before setting the enabled flag.
Move the decl of err to function scope.
Fixes: 2b2f5ff00f
("rtc: interface: ignore expired timers when enqueuing new timers")
Signed-off-by: Tom Rix <trix@redhat.com>
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
Link: https://lore.kernel.org/r/20220326194236.2916310-1-trix@redhat.com
(cherry picked from commit 915593a7a663b2ad08b895a5f3ba8b19d89d4ebf)
Signed-off-by: Al Stone <ahs3@redhat.com>
This commit is contained in:
parent
3a7e8148af
commit
e8d4a7607a
|
@ -804,9 +804,13 @@ static int rtc_timer_enqueue(struct rtc_device *rtc, struct rtc_timer *timer)
|
||||||
struct timerqueue_node *next = timerqueue_getnext(&rtc->timerqueue);
|
struct timerqueue_node *next = timerqueue_getnext(&rtc->timerqueue);
|
||||||
struct rtc_time tm;
|
struct rtc_time tm;
|
||||||
ktime_t now;
|
ktime_t now;
|
||||||
|
int err;
|
||||||
|
|
||||||
|
err = __rtc_read_time(rtc, &tm);
|
||||||
|
if (err)
|
||||||
|
return err;
|
||||||
|
|
||||||
timer->enabled = 1;
|
timer->enabled = 1;
|
||||||
__rtc_read_time(rtc, &tm);
|
|
||||||
now = rtc_tm_to_ktime(tm);
|
now = rtc_tm_to_ktime(tm);
|
||||||
|
|
||||||
/* Skip over expired timers */
|
/* Skip over expired timers */
|
||||||
|
@ -820,7 +824,6 @@ static int rtc_timer_enqueue(struct rtc_device *rtc, struct rtc_timer *timer)
|
||||||
trace_rtc_timer_enqueue(timer);
|
trace_rtc_timer_enqueue(timer);
|
||||||
if (!next || ktime_before(timer->node.expires, next->expires)) {
|
if (!next || ktime_before(timer->node.expires, next->expires)) {
|
||||||
struct rtc_wkalrm alarm;
|
struct rtc_wkalrm alarm;
|
||||||
int err;
|
|
||||||
|
|
||||||
alarm.time = rtc_ktime_to_tm(timer->node.expires);
|
alarm.time = rtc_ktime_to_tm(timer->node.expires);
|
||||||
alarm.enabled = 1;
|
alarm.enabled = 1;
|
||||||
|
|
Loading…
Reference in New Issue