Re: workqueue: Is flush_work() without INIT_WORK() OK?

From: Tejun Heo
Date: Fri Jan 18 2019 - 09:05:33 EST


Hello, Tetsuo.

On Fri, Jan 18, 2019 at 08:58:49PM +0900, Tetsuo Handa wrote:
> struct work_struct work;
> memset(&work, 0, sizeof(work));
> flush_work(&work);
>
> . Is this behavior defined as "safe and no-op"? If this should be "safe and no-op",

Nope, that's a bug.

> we need to check whether INIT_WORK() was called before starting lockdep checks
> at __flush_work(). If this is not "safe and no-op", I want to emit a warning if
> INIT_WORK() was not called.

Sounds like a good idea.

Thanks.

--
tejun