public inbox for linux-kernel-mentees@lists.linux-foundation.org
 help / color / mirror / Atom feed
* [PATCH] rtc: fix use of uninit struct in rtc_read_alarm_internal
@ 2025-03-17 18:33 Bharadwaj Raju
  2025-03-17 21:51 ` Alexandre Belloni
  0 siblings, 1 reply; 4+ messages in thread
From: Bharadwaj Raju @ 2025-03-17 18:33 UTC (permalink / raw)
  To: alexandre.belloni
  Cc: Bharadwaj Raju, linux-rtc, shuah, linux-kernel,
	linux-kernel-mentees

The trace call invokes rtc_tm_to_time64 on a
potentially uninitialized alarm->time. Move the
trace call to the path where we do successfully
initialize and read that struct.

This fixes a KMSAN warning.

Fixes: 29a1f599c0cc ("rtc: Add tracepoints for RTC system")

Signed-off-by: Bharadwaj Raju <bharadwaj.raju777@gmail.com>
---
 drivers/rtc/interface.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/rtc/interface.c b/drivers/rtc/interface.c
index aaf76406cd7d..82ba33bf478b 100644
--- a/drivers/rtc/interface.c
+++ b/drivers/rtc/interface.c
@@ -201,11 +201,12 @@ static int rtc_read_alarm_internal(struct rtc_device *rtc,
 		alarm->time.tm_yday = -1;
 		alarm->time.tm_isdst = -1;
 		err = rtc->ops->read_alarm(rtc->dev.parent, alarm);
+		if (!err)
+			trace_rtc_read_alarm(rtc_tm_to_time64(&alarm->time), err);
 	}
 
 	mutex_unlock(&rtc->ops_lock);
 
-	trace_rtc_read_alarm(rtc_tm_to_time64(&alarm->time), err);
 	return err;
 }
 
-- 
2.48.1


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

end of thread, other threads:[~2025-04-08 14:44 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-03-17 18:33 [PATCH] rtc: fix use of uninit struct in rtc_read_alarm_internal Bharadwaj Raju
2025-03-17 21:51 ` Alexandre Belloni
2025-03-29 14:29   ` Bharadwaj Raju
2025-04-08 14:44     ` Alexandre Belloni

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