On Sun, 30 Aug 2026 14:52:52 +0000 [email protected] wrote: > [Severity: Medium] > Will this trigger a kernel warning in __flush_work() if the work struct has > not been initialized yet? > > In alloc_trace_wprobe(), if the kstrdup() allocation for the symbol fails, > the function returns early. Since the tw pointer is managed by the > __free(free_trace_wprobe) guard, it will automatically invoke this cleanup > function: > > alloc_trace_wprobe() { > ... > tw = kzalloc_flex(*tw, tp.args, nargs); > ... > if (symbol) { > tw->symbol = kstrdup(symbol, GFP_KERNEL); > if (!tw->symbol) > return ERR_PTR(-ENOMEM); /* triggers free_trace_wprobe(tw) */ > } > ... > INIT_WORK(&tw->work, wprobe_work_func); > } > > Because the early return happens before INIT_WORK() is called, > cancel_work_sync() will operate on a zeroed work_struct, which can cause a > WARN_ON(!work->func).
Oops, good catch! OK, I'll move the initialize those first and also check tw->work.func in free_trace_wprobe() for safety. Thank you! -- Masami Hiramatsu (Google) <[email protected]>
