Re: [PATCH] workqueue: Fix double kfree(rescuer) in destroy_workqueue()

From: qzhang2
Date: Mon May 25 2020 - 02:43:45 EST

Sorry I didn't describe clearly

I describe the meaning as follows:

struct worker *rescuer = wq->rescuer
kfree(rescuer) //first kfree

if (!(wq->flags & WQ_UNBOUND))
call_rcu(&wq->rcu, rcu_free_wq)

kfree(wq->rescuer) //second kfree

there are double free.

On 5/24/20 11:33 PM, Markus Elfring wrote:
When destroy_workqueue if rescuer worker exist,wq->rescuer pointer be
kfree. if sanity checks passed. the func call_rcu(&wq->rcu, rcu_free_wq)
will be called if the wq->flags & WQ_UNBOUND is false,in rcu_free_wq
func wq->rescuer pointer was kfree again.

1. I suggest to improve also this change description.
Do you try to explain here that a call of the function âfree_workqueue_attrsâ
(or âfree_percpuâ) would perform sufficient clean-up of system resources
in this use case?

2. You proposed to delete the function call âkfree(wq->rescuer)â from
the implementation of the function ârcu_free_wqâ.

This function name should be specified also in the patch subject,
shouldn't it?

3. Would you like to add the tag âFixesâ to the commit message?