This is an automated email from the ASF dual-hosted git repository.

xiaoxiang781216 pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx.git

commit 7895c213d5b14a9e8136180833d00c7aa633264d
Author: huojianchao <[email protected]>
AuthorDate: Wed Dec 24 16:56:18 2025 +0800

    drivers/timers/arch_rtc: zero struct rtc_time before rdtime()
    
    up_rtc_getdatetime_with_subseconds() returns the tm_nsec of a local
    struct rtc_time, so with a lower half that does not set tm_nsec it
    returned stack garbage, and clock_basetime() could start the system time
    with a tv_nsec above 999999999.
    
    Zero the struct before calling rdtime(), as up_rtc_gettime() does.
    
    Signed-off-by: huojianchao <[email protected]>
---
 drivers/timers/arch_rtc.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/drivers/timers/arch_rtc.c b/drivers/timers/arch_rtc.c
index 08dd31102af..e92fdd12b80 100644
--- a/drivers/timers/arch_rtc.c
+++ b/drivers/timers/arch_rtc.c
@@ -219,7 +219,10 @@ int weak_function up_rtc_getdatetime_with_subseconds(FAR 
struct tm *tp,
 
   if (g_rtc_lower != NULL)
     {
-      struct rtc_time rtctime;
+      struct rtc_time rtctime =
+        {
+          0
+        };
 
       ret = g_rtc_lower->ops->rdtime(g_rtc_lower, &rtctime);
       if (ret == 0)

Reply via email to