From 6e1167444c7dd3491739618c6b0481587ac5bdb1 Mon Sep 17 00:00:00 2001 From: Ian Abbott Date: Wed, 17 Apr 2019 16:32:49 +0100 Subject: [PATCH] staging: comedi: ni_usb6501: Call mutex_destroy() on private mutex `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 Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/ni_usb6501.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/drivers/staging/comedi/drivers/ni_usb6501.c b/drivers/staging/comedi/drivers/ni_usb6501.c index 808ed92ed66f..0e38f69aa8b6 100644 --- a/drivers/staging/comedi/drivers/ni_usb6501.c +++ b/drivers/staging/comedi/drivers/ni_usb6501.c @@ -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 = {