History

staging: comedi: bug-fix NULL pointer dereference on failed attach

Commit dcd7b8bd63cb81c5b973bf86510ca3c80bbbd162 ("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.

Ian Abbott committed 13 years ago

Commit 3955dfa1 parent 06cdff81 file · +1 −1Browse files

Unified · Split

drivers/staging/comedi/drivers.c+1−1
@@ -482,7 +482,7 @@ int comedi_device_attach(struct comedi_device *dev, struct comedi_devconfig *it) · 481 unmodified lines
482 ret = comedi_device_postconfig(dev);482 ret = comedi_device_postconfig(dev);
483 if (ret < 0) {483 if (ret < 0) {
484 comedi_device_detach(dev);484 comedi_device_detach(dev);
485 module_put(dev->driver->module);485 module_put(driv->module);
486 }486 }
487 /* On success, the driver module count has been incremented. */487 /* On success, the driver module count has been incremented. */
488 return ret;488 return ret;

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t