Skip to content

Commit

Permalink
staging: comedi: ni_usb6501: Call mutex_destroy() on private mutex
Browse files Browse the repository at this point in the history
`ni6501_detach()` is the Comedi "detach" handler for the ni_usb6501
driver.  It is called when the private data for the device is about to
be freed.  The private data contains a mutex `devpriv->mut` that was
initialized when the private data was allocated.  Call `mutex_destroy()`
to mark it as invalid.

Also remove the calls to `mutex_lock()` and `mutex_unlock()` from
`ni6501_detach()`.  The only other locks of the mutex are by some of the
Comedi instruction handlers that cannot contend with the "detach"
handler for this mutex.

Signed-off-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
  • Loading branch information
Ian Abbott authored and Greg Kroah-Hartman committed Apr 19, 2019
1 parent 3c03c47 commit 6e11674
Showing 1 changed file with 1 addition and 3 deletions.
4 changes: 1 addition & 3 deletions drivers/staging/comedi/drivers/ni_usb6501.c
Original file line number Diff line number Diff line change
Expand Up @@ -564,14 +564,12 @@ static void ni6501_detach(struct comedi_device *dev)
if (!devpriv)
return;

mutex_lock(&devpriv->mut);
mutex_destroy(&devpriv->mut);

usb_set_intfdata(intf, NULL);

kfree(devpriv->usb_rx_buf);
kfree(devpriv->usb_tx_buf);

mutex_unlock(&devpriv->mut);
}

static struct comedi_driver ni6501_driver = {
Expand Down

0 comments on commit 6e11674

Please sign in to comment.