Re: [PATCH v3 07/22] kthread: Detect when a kthread work is used by more workers

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, Nov 24, 2015 at 11:06:50AM +0100, Petr Mladek wrote:
> On Mon 2015-11-23 17:27:03, Tejun Heo wrote:
> > Hello,
> > 
> > On Wed, Nov 18, 2015 at 02:25:12PM +0100, Petr Mladek wrote:
> > > @@ -610,6 +625,12 @@ repeat:
> > >  	if (work) {
> > >  		__set_current_state(TASK_RUNNING);
> > >  		work->func(work);
> > > +
> > > +		spin_lock_irq(&worker->lock);
> > > +		/* Allow to queue the work into another worker */
> > > +		if (!kthread_work_pending(work))
> > > +			work->worker = NULL;
> > > +		spin_unlock_irq(&worker->lock);
> > 
> > Doesn't this mean that the work item can't be freed from its callback?
> > That pattern tends to happen regularly.
> 
> I am not sure if I understand your question. Do you mean switching
> work->func during the life time of the struct kthread_work? This
> should not be affected by the above code.

No, work->func(work) doing: kfree(work).

That is indeed something quite frequently done, and since you now have
references to work after calling func, things would go *boom* rather
quickly.
--
To unsubscribe from this list: send the line "unsubscribe linux-api" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux