diff options
author | H Hartley Sweeten <hsweeten@visionengravers.com> | 2013-06-24 16:23:00 -0700 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2013-06-24 16:43:40 -0700 |
commit | 7f5ac6f4f595b4b17b15ff6701f07377bea8ffd3 (patch) | |
tree | e2431be18a85815eb60251a78c4dca13ed5f10fe /drivers/staging | |
parent | 27a9095aa00426f80660df0e5f857a06852e1496 (diff) | |
download | linux-stable-7f5ac6f4f595b4b17b15ff6701f07377bea8ffd3.tar.gz linux-stable-7f5ac6f4f595b4b17b15ff6701f07377bea8ffd3.tar.bz2 linux-stable-7f5ac6f4f595b4b17b15ff6701f07377bea8ffd3.zip |
staging: comedi: unioxx5: fix unioxx5_detach()
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>
Diffstat (limited to 'drivers/staging')
-rw-r--r-- | drivers/staging/comedi/drivers/unioxx5.c | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/drivers/staging/comedi/drivers/unioxx5.c b/drivers/staging/comedi/drivers/unioxx5.c index d05d46d0a1f2..fc88b66f408d 100644 --- a/drivers/staging/comedi/drivers/unioxx5.c +++ b/drivers/staging/comedi/drivers/unioxx5.c @@ -474,15 +474,16 @@ static int unioxx5_attach(struct comedi_device *dev, 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); } } |