Skip to content

Commit

Permalink
mei: nfc: fix deadlock on shutdown/suspend path
Browse files Browse the repository at this point in the history
In function mei_nfc_host_exit mei_cl_remove_device cannot be called
under the device mutex as device removing flow invokes the device driver
remove handler that calls in turn to mei_cl_disable_device which
naturally acquires the device mutex.

Also remove mei_cl_bus_remove_devices which has the same issue, but is
never executed as currently the only device on the mei client bus is NFC
and a new device cannot be easily added till the bus revamp is
completed.

This fixes regression caused by commit be9b720 ("mei_phy: move all
nfc logic from mei driver to nfc")

Prior to this change the nfc driver remove handler called to no-op
disable function while actual nfc device was disabled directly from the
mei driver.

Reported-by: Linus Torvalds <torvalds@linux-foundation.org>
Acked-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Samuel Ortiz <sameo@linux.intel.com>
Signed-off-by: Tomas Winkler <tomas.winkler@intel.com>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
  • Loading branch information
Tomas Winkler authored and Linus Torvalds committed Jul 7, 2015
1 parent c7e9ad7 commit 4f27395
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 19 deletions.
16 changes: 0 additions & 16 deletions drivers/misc/mei/bus.c
Original file line number Diff line number Diff line change
Expand Up @@ -552,22 +552,6 @@ void mei_cl_bus_rx_event(struct mei_cl *cl)
schedule_work(&device->event_work);
}

void mei_cl_bus_remove_devices(struct mei_device *dev)
{
struct mei_cl *cl, *next;

mutex_lock(&dev->device_lock);
list_for_each_entry_safe(cl, next, &dev->device_list, device_link) {
if (cl->device)
mei_cl_remove_device(cl->device);

list_del(&cl->device_link);
mei_cl_unlink(cl);
kfree(cl);
}
mutex_unlock(&dev->device_lock);
}

int __init mei_cl_bus_init(void)
{
return bus_register(&mei_cl_bus_type);
Expand Down
2 changes: 0 additions & 2 deletions drivers/misc/mei/init.c
Original file line number Diff line number Diff line change
Expand Up @@ -333,8 +333,6 @@ void mei_stop(struct mei_device *dev)

mei_nfc_host_exit(dev);

mei_cl_bus_remove_devices(dev);

mutex_lock(&dev->device_lock);

mei_wd_stop(dev);
Expand Down
3 changes: 2 additions & 1 deletion drivers/misc/mei/nfc.c
Original file line number Diff line number Diff line change
Expand Up @@ -402,11 +402,12 @@ void mei_nfc_host_exit(struct mei_device *dev)

cldev->priv_data = NULL;

mutex_lock(&dev->device_lock);
/* Need to remove the device here
* since mei_nfc_free will unlink the clients
*/
mei_cl_remove_device(cldev);

mutex_lock(&dev->device_lock);
mei_nfc_free(ndev);
mutex_unlock(&dev->device_lock);
}
Expand Down

0 comments on commit 4f27395

Please sign in to comment.