]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blame - queue-5.10/timers-rename-del_timer_sync-to-timer_delete_sync.patch
Fixes for 5.10
[thirdparty/kernel/stable-queue.git] / queue-5.10 / timers-rename-del_timer_sync-to-timer_delete_sync.patch
CommitLineData
b7ca0ba0
SL
1From e317d6f28dc39f27f561d8cffd1f927282b51ddc Mon Sep 17 00:00:00 2001
2From: Sasha Levin <sashal@kernel.org>
3Date: Wed, 23 Nov 2022 21:18:44 +0100
4Subject: timers: Rename del_timer_sync() to timer_delete_sync()
5
6From: Thomas Gleixner <tglx@linutronix.de>
7
8[ Upstream commit 9b13df3fb64ee95e2397585404e442afee2c7d4f ]
9
10The timer related functions do not have a strict timer_ prefixed namespace
11which is really annoying.
12
13Rename del_timer_sync() to timer_delete_sync() and provide del_timer_sync()
14as a wrapper. Document that del_timer_sync() is not for new code.
15
16Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
17Tested-by: Guenter Roeck <linux@roeck-us.net>
18Reviewed-by: Steven Rostedt (Google) <rostedt@goodmis.org>
19Reviewed-by: Jacob Keller <jacob.e.keller@intel.com>
20Reviewed-by: Anna-Maria Behnsen <anna-maria@linutronix.de>
21Link: https://lore.kernel.org/r/20221123201624.954785441@linutronix.de
22Stable-dep-of: 0f7352557a35 ("wifi: brcmfmac: Fix use-after-free bug in brcmf_cfg80211_detach")
23Signed-off-by: Sasha Levin <sashal@kernel.org>
24---
25 include/linux/timer.h | 15 ++++++++++++++-
26 kernel/time/timer.c | 18 +++++++++---------
27 2 files changed, 23 insertions(+), 10 deletions(-)
28
29diff --git a/include/linux/timer.h b/include/linux/timer.h
30index a3125373139e1..a3d04c4f1263a 100644
31--- a/include/linux/timer.h
32+++ b/include/linux/timer.h
33@@ -183,7 +183,20 @@ extern int timer_reduce(struct timer_list *timer, unsigned long expires);
34 extern void add_timer(struct timer_list *timer);
35
36 extern int try_to_del_timer_sync(struct timer_list *timer);
37-extern int del_timer_sync(struct timer_list *timer);
38+extern int timer_delete_sync(struct timer_list *timer);
39+
40+/**
41+ * del_timer_sync - Delete a pending timer and wait for a running callback
42+ * @timer: The timer to be deleted
43+ *
44+ * See timer_delete_sync() for detailed explanation.
45+ *
46+ * Do not use in new code. Use timer_delete_sync() instead.
47+ */
48+static inline int del_timer_sync(struct timer_list *timer)
49+{
50+ return timer_delete_sync(timer);
51+}
52
53 #define del_singleshot_timer_sync(t) del_timer_sync(t)
54
55diff --git a/kernel/time/timer.c b/kernel/time/timer.c
56index 9edce790b3aa5..c135cefa44ac0 100644
57--- a/kernel/time/timer.c
58+++ b/kernel/time/timer.c
59@@ -1030,7 +1030,7 @@ __mod_timer(struct timer_list *timer, unsigned long expires, unsigned int option
60 /*
61 * We are trying to schedule the timer on the new base.
62 * However we can't change timer's base while it is running,
63- * otherwise del_timer_sync() can't detect that the timer's
64+ * otherwise timer_delete_sync() can't detect that the timer's
65 * handler yet has not finished. This also guarantees that the
66 * timer is serialized wrt itself.
67 */
68@@ -1206,7 +1206,7 @@ EXPORT_SYMBOL_GPL(add_timer_on);
69 * @timer: The timer to be deactivated
70 *
71 * The function only deactivates a pending timer, but contrary to
72- * del_timer_sync() it does not take into account whether the timer's
73+ * timer_delete_sync() it does not take into account whether the timer's
74 * callback function is concurrently executed on a different CPU or not.
75 * It neither prevents rearming of the timer. If @timer can be rearmed
76 * concurrently then the return value of this function is meaningless.
77@@ -1342,7 +1342,7 @@ static inline void del_timer_wait_running(struct timer_list *timer) { }
78 #endif
79
80 /**
81- * del_timer_sync - Deactivate a timer and wait for the handler to finish.
82+ * timer_delete_sync - Deactivate a timer and wait for the handler to finish.
83 * @timer: The timer to be deactivated
84 *
85 * Synchronization rules: Callers must prevent restarting of the timer,
86@@ -1364,10 +1364,10 @@ static inline void del_timer_wait_running(struct timer_list *timer) { }
87 * spin_lock_irq(somelock);
88 * <IRQ>
89 * spin_lock(somelock);
90- * del_timer_sync(mytimer);
91+ * timer_delete_sync(mytimer);
92 * while (base->running_timer == mytimer);
93 *
94- * Now del_timer_sync() will never return and never release somelock.
95+ * Now timer_delete_sync() will never return and never release somelock.
96 * The interrupt on the other CPU is waiting to grab somelock but it has
97 * interrupted the softirq that CPU0 is waiting to finish.
98 *
99@@ -1380,7 +1380,7 @@ static inline void del_timer_wait_running(struct timer_list *timer) { }
100 * * %0 - The timer was not pending
101 * * %1 - The timer was pending and deactivated
102 */
103-int del_timer_sync(struct timer_list *timer)
104+int timer_delete_sync(struct timer_list *timer)
105 {
106 int ret;
107
108@@ -1413,7 +1413,7 @@ int del_timer_sync(struct timer_list *timer)
109
110 return ret;
111 }
112-EXPORT_SYMBOL(del_timer_sync);
113+EXPORT_SYMBOL(timer_delete_sync);
114
115 static void call_timer_fn(struct timer_list *timer,
116 void (*fn)(struct timer_list *),
117@@ -1435,8 +1435,8 @@ static void call_timer_fn(struct timer_list *timer,
118 #endif
119 /*
120 * Couple the lock chain with the lock chain at
121- * del_timer_sync() by acquiring the lock_map around the fn()
122- * call here and in del_timer_sync().
123+ * timer_delete_sync() by acquiring the lock_map around the fn()
124+ * call here and in timer_delete_sync().
125 */
126 lock_map_acquire(&lockdep_map);
127
128--
1292.43.0
130