Re: [PATCH v2] workqueue: Fix double kfree for rescuer

From: Markus Elfring
Date: Mon May 25 2020 - 05:50:32 EST

> The duplicate memory release should be deleted from the implementation
> of the callback function "rcu_free_wq".

I tried to help with the selection of a better commit message.
I have taken another look also at the implementation of the function âdestroy_workqueueâ.

* The function call âdestroy_workqueueâ can be performed there in an if branch
after the statement âwq->rescuer = NULLâ was executed.

* This data processing is independent from a possible call of the
function âcall_rcu(&wq->rcu, rcu_free_wq)â in another if branch.
Thus it seems that a null pointer is intentionally passed by a data structure
member to this callback function on demand.
The corresponding call of the function âkfreeâ can tolerate this special case.

Now I find that the proposed change can be inappropriate.