Skip to content

Commit

Permalink
staging: comedi: bug-fix NULL pointer dereference on failed attach
Browse files Browse the repository at this point in the history
Commit dcd7b8b ("staging: comedi: put
module _after_ detach" by myself) reversed a couple of calls in
`comedi_device_attach()` when recovering from an error returned by the
low-level driver's 'attach' handler.  Unfortunately, that introduced a
NULL pointer dereference bug as `dev->driver` is NULL after the call to
`comedi_device_detach()`.   We still have a pointer to the low-level
comedi driver structure in the `driv` variable, so use that instead.

Signed-off-by: Ian Abbott <abbotti@mev.co.uk>
Cc: <stable@vger.kernel.org> # 3.10+
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
  • Loading branch information
Ian Abbott authored and Greg Kroah-Hartman committed Aug 23, 2013
1 parent 06cdff8 commit 3955dfa
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion drivers/staging/comedi/drivers.c
Original file line number Diff line number Diff line change
Expand Up @@ -482,7 +482,7 @@ int comedi_device_attach(struct comedi_device *dev, struct comedi_devconfig *it)
ret = comedi_device_postconfig(dev);
if (ret < 0) {
comedi_device_detach(dev);
module_put(dev->driver->module);
module_put(driv->module);
}
/* On success, the driver module count has been incremented. */
return ret;
Expand Down

0 comments on commit 3955dfa

Please sign in to comment.