summaryrefslogtreecommitdiffstats
path: root/drivers/staging/comedi
diff options
context:
space:
mode:
authorIan Abbott2019-04-17 16:35:31 +0200
committerGreg Kroah-Hartman2019-04-19 14:33:33 +0200
commitf439696c81fcfe70ad46554fbec1c851bab9345a (patch)
tree638ea57d98baad0fa8efd60b8212680cf80104f9 /drivers/staging/comedi
parentstaging: wilc1000: Avoid GFP_KERNEL allocation from atomic context (diff)
downloadkernel-qcow2-linux-f439696c81fcfe70ad46554fbec1c851bab9345a.tar.gz
kernel-qcow2-linux-f439696c81fcfe70ad46554fbec1c851bab9345a.tar.xz
kernel-qcow2-linux-f439696c81fcfe70ad46554fbec1c851bab9345a.zip
staging: comedi: don't release mutex too early in comedi_auto_config()
`comedi_auto_config()` uses `dev->class_dev` for logging a kernel message after releasing `dev->mutex`. There is an unlikely possibility that the Comedi device `dev` will have been removed by the `COMEDI_DEVCONFIG` ioctl() command. Keep hold of the mutex until the kernel message has been sent to prevent that. The function can call `comedi_release_hardware_device()` on error. In that case, the mutex must be unlocked before that. Signed-off-by: Ian Abbott <abbotti@mev.co.uk> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/staging/comedi')
-rw-r--r--drivers/staging/comedi/drivers.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/drivers/staging/comedi/drivers.c b/drivers/staging/comedi/drivers.c
index 5a32b8fc000e..b7b9e48d4303 100644
--- a/drivers/staging/comedi/drivers.c
+++ b/drivers/staging/comedi/drivers.c
@@ -1059,12 +1059,12 @@ int comedi_auto_config(struct device *hardware_device,
ret = driver->auto_attach(dev, context);
if (ret >= 0)
ret = comedi_device_postconfig(dev);
- mutex_unlock(&dev->mutex);
if (ret < 0) {
dev_warn(hardware_device,
"driver '%s' failed to auto-configure device.\n",
driver->driver_name);
+ mutex_unlock(&dev->mutex);
comedi_release_hardware_device(hardware_device);
} else {
/*
@@ -1074,6 +1074,7 @@ int comedi_auto_config(struct device *hardware_device,
dev_info(dev->class_dev,
"driver '%s' has successfully auto-configured '%s'.\n",
driver->driver_name, dev->board_name);
+ mutex_unlock(&dev->mutex);
}
return ret;
}