During the attach of this driver, it's possible for the allocation
of the subdevice private data to fail. It's also possible that the
io region was not successfully requested.
Validate the pointer and iobase before trying to release the region.
For aesthetic reasons, rename the local variables.
Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Cc: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
static void unioxx5_detach(struct comedi_device *dev)
{
+ struct comedi_subdevice *s;
+ struct unioxx5_subd_priv *spriv;
int i;
- struct comedi_subdevice *subdev;
- struct unioxx5_subd_priv *usp;
for (i = 0; i < dev->n_subdevices; i++) {
- subdev = &dev->subdevices[i];
- usp = subdev->private;
- release_region(usp->usp_iobase, UNIOXX5_SIZE);
- kfree(subdev->private);
+ s = &dev->subdevices[i];
+ spriv = s->private;
+ if (spriv && spriv->usp_iobase)
+ release_region(spriv->usp_iobase, UNIOXX5_SIZE);
+ kfree(spriv);
}
}