]> git.baikalelectronics.ru Git - kernel.git/commit
rtc: check if __rtc_read_time was successful
authorTom Rix <trix@redhat.com>
Sat, 26 Mar 2022 19:42:36 +0000 (12:42 -0700)
committerAlexandre Belloni <alexandre.belloni@bootlin.com>
Tue, 29 Mar 2022 20:45:50 +0000 (22:45 +0200)
commit9b59661611f7d08bb7dbaa64d2f4052a3368210e
treeb0921c38fe1b4ac67b40cfb221562b5c01c50f78
parent52285580c2545988e1ca1ed0aa458b4f1ce0cbb0
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: fed8a941785a ("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
drivers/rtc/interface.c