Re: [PATCH] spi: Fix hung task timeout when initialization fails

From: Mark Brown
Date: Thu May 01 2014 - 12:09:44 EST


On Thu, May 01, 2014 at 10:15:15AM +0200, Ricardo Ribalda Delgado wrote:

> If kthread_run on spi_init_queue() fails, spi_destroy_queue can lead to
> hang timeout.

...

> When this happens, spi_destroy_queue() leads to a hung process that
> outputs a error message and avoids the computer to be halted/rebooted.

Why is the fix for this not to avoid running spi_destroy_queue() in the
first place? I would not in general expect it to be robust to call the
destructor function if the init function failed (and indeed this looks
like what's happening with the kthread code here) - even if it works now
it seems like it will be a source of bugs in the future.

> - flush_kthread_worker(&master->kworker);
> - kthread_stop(master->kworker_task);
> + if (!IS_ERR(master->kworker_task)) {
> + flush_kthread_worker(&master->kworker);
> + kthread_stop(master->kworker_task);
> + }

This still just looks like a race condition.

Attachment: signature.asc
Description: Digital signature