Skip to content

Commit ea2e64f

Browse files
committed
workqueue: Provide destroy_delayed_work_on_stack()
If a delayed or deferrable work is on stack we need to tell debug objects that we are destroying the timer and the work. Otherwise we leak the tracking object. Signed-off-by: Thomas Gleixner <[email protected]> Cc: Vince Weaver <[email protected]> Acked-by: Tejun Heo <[email protected]> Link: http://lkml.kernel.org/r/[email protected] Signed-off-by: Thomas Gleixner <[email protected]>
1 parent 87291a9 commit ea2e64f

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

include/linux/workqueue.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -191,13 +191,15 @@ struct execute_work {
191191
#ifdef CONFIG_DEBUG_OBJECTS_WORK
192192
extern void __init_work(struct work_struct *work, int onstack);
193193
extern void destroy_work_on_stack(struct work_struct *work);
194+
extern void destroy_delayed_work_on_stack(struct delayed_work *work);
194195
static inline unsigned int work_static(struct work_struct *work)
195196
{
196197
return *work_data_bits(work) & WORK_STRUCT_STATIC;
197198
}
198199
#else
199200
static inline void __init_work(struct work_struct *work, int onstack) { }
200201
static inline void destroy_work_on_stack(struct work_struct *work) { }
202+
static inline void destroy_delayed_work_on_stack(struct delayed_work *work) { }
201203
static inline unsigned int work_static(struct work_struct *work) { return 0; }
202204
#endif
203205

kernel/workqueue.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -516,6 +516,13 @@ void destroy_work_on_stack(struct work_struct *work)
516516
}
517517
EXPORT_SYMBOL_GPL(destroy_work_on_stack);
518518

519+
void destroy_delayed_work_on_stack(struct delayed_work *work)
520+
{
521+
destroy_timer_on_stack(&work->timer);
522+
debug_object_free(&work->work, &work_debug_descr);
523+
}
524+
EXPORT_SYMBOL_GPL(destroy_delayed_work_on_stack);
525+
519526
#else
520527
static inline void debug_work_activate(struct work_struct *work) { }
521528
static inline void debug_work_deactivate(struct work_struct *work) { }

0 commit comments

Comments
 (0)