[PATCH 16/37] staging: comedi: put module _after_ detach

Ian Abbott abbotti at mev.co.uk
Thu Apr 4 13:58:57 UTC 2013


On failure of the call to the low-level comedi device driver's
`->attach()` handler from `__comedi_device_attach()`, reverse the
current ordering of the calls to `module_put()` and
`comedi_device_detach()` because `__comedi_device_detach()` will call
code in the module being put.

Signed-off-by: Ian Abbott <abbotti at mev.co.uk>
---
 drivers/staging/comedi/drivers.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/staging/comedi/drivers.c b/drivers/staging/comedi/drivers.c
index 73727a7..6f232b8 100644
--- a/drivers/staging/comedi/drivers.c
+++ b/drivers/staging/comedi/drivers.c
@@ -396,8 +396,8 @@ int comedi_device_attach(struct comedi_device *dev, struct comedi_devconfig *it)
 	dev->driver = driv;
 	ret = driv->attach(dev, it);
 	if (ret < 0) {
-		module_put(dev->driver->module);
 		__comedi_device_detach(dev);
+		module_put(dev->driver->module);
 		return ret;
 	}
 	ret = comedi_device_postconfig(dev);
-- 
1.8.1.5




More information about the devel mailing list