summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarkus Blöchl <markus@blochl.de>2025-07-20 15:54:51 +0200
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2025-08-01 09:48:42 +0100
commit9ea8a9ebbea8276e74b49bcaf06a83e449d97c35 (patch)
tree1b56621f0508f4392caf37783fe372edf3d74e6b
parent6ed79cf1183a71f18a3eeb33fff87b06ed21e27c (diff)
timekeeping: Zero initialize system_counterval when querying time from phc drivers
commit 67c632b4a7fbd6b76a08b86f4950f0f84de93439 upstream. Most drivers only populate the fields cycles and cs_id of system_counterval in their get_time_fn() callback for get_device_system_crosststamp(), unless they explicitly provide nanosecond values. When the use_nsecs field was added to struct system_counterval, most drivers did not care. Clock sources other than CSID_GENERIC could then get converted in convert_base_to_cs() based on an uninitialized use_nsecs field, which usually results in -EINVAL during the following range check. Pass in a fully zero initialized system_counterval_t to cure that. Fixes: 6b2e29977518 ("timekeeping: Provide infrastructure for converting to/from a base clock") Signed-off-by: Markus Blöchl <markus@blochl.de> Signed-off-by: Thomas Gleixner <tglx@linutronix.de> Acked-by: John Stultz <jstultz@google.com> Cc: stable@vger.kernel.org Link: https://lore.kernel.org/all/20250720-timekeeping_uninit_crossts-v2-1-f513c885b7c2@blochl.de Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-rw-r--r--kernel/time/timekeeping.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/kernel/time/timekeeping.c b/kernel/time/timekeeping.c
index 96933082431f..e3896b2be453 100644
--- a/kernel/time/timekeeping.c
+++ b/kernel/time/timekeeping.c
@@ -1218,7 +1218,7 @@ int get_device_system_crosststamp(int (*get_time_fn)
struct system_time_snapshot *history_begin,
struct system_device_crosststamp *xtstamp)
{
- struct system_counterval_t system_counterval;
+ struct system_counterval_t system_counterval = {};
struct timekeeper *tk = &tk_core.timekeeper;
u64 cycles, now, interval_start;
unsigned int clock_was_set_seq = 0;