staging: comedi: put module _after_ detach
authorIan Abbott <abbotti@mev.co.uk>
Thu, 4 Apr 2013 13:58:57 +0000 (14:58 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 5 Apr 2013 21:33:18 +0000 (14:33 -0700)
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@mev.co.uk>
Reviewed-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/staging/comedi/drivers.c

index 73727a73bd34c69fe0c8c527d05eed5099e66c2b..6f232b8128c07a9c61e26094bca010315dd2b2c2 100644 (file)
@@ -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);