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

From: Tetsuo Handa
Date: Fri Jan 18 2019 - 06:58:56 EST


Hello, Tejun.

syzbot is reporting "INFO: trying to register non-static key in __flush_work"
at https://syzkaller.appspot.com/bug?id=a5954455fcfa51c29ca2ab55b203076337e1c770 ,
and I think that the caller is passing a work_struct allocated by kzalloc() to
flush_work().

But I can't judge which problem (the caller side or the WQ side) without knowing
the behavior of

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",
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.