mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] timer: mask unnecessary set of flags in do_init_timer
@ 2020-08-07  2:29 Qianli Zhao
  2020-08-13 10:46 ` Thomas Gleixner
  0 siblings, 1 reply; 3+ messages in thread
From: Qianli Zhao @ 2020-08-07  2:29 UTC (permalink / raw)
  To: tglx, john.stultz, sboyd; +Cc: linux-kernel, zhaoqianli

From: Qianli Zhao <zhaoqianli@xiaomi.com>

do_init_timer can specify flags of timer_list,
but this function does not expect to specify the CPU or idx.
If user invoking do_init_timer and specify CPU,
The result may not what we expected.

E.g:
do_init_timer invoked in core2,and specify flags 0x1
final result flags is 0x3.If the specified CPU number
exceeds the actual number,more serious problems will happen

Signed-off-by: Qianli Zhao <zhaoqianli@xiaomi.com>
---
 kernel/time/timer.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/kernel/time/timer.c b/kernel/time/timer.c
index 026ac01..17e3737 100644
--- a/kernel/time/timer.c
+++ b/kernel/time/timer.c
@@ -789,7 +789,7 @@ static void do_init_timer(struct timer_list *timer,
 {
 	timer->entry.pprev = NULL;
 	timer->function = func;
-	timer->flags = flags | raw_smp_processor_id();
+	timer->flags = (flags & ~TIMER_BASEMASK & ~TIMER_ARRAYMASK) | raw_smp_processor_id();
 	lockdep_init_map(&timer->lockdep_map, name, key, 0);
 }
 
-- 
2.7.4


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

end of thread, other threads:[~2020-08-13 15:17 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-08-07  2:29 [PATCH] timer: mask unnecessary set of flags in do_init_timer Qianli Zhao
2020-08-13 10:46 ` Thomas Gleixner
2020-08-13 15:17   ` qianli zhao

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

all inboxes | Powered by JetHome®