aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorH Hartley Sweeten <hsweeten@visionengravers.com>2013-06-24 19:23:00 -0400
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2013-06-24 19:43:40 -0400
commit7f5ac6f4f595b4b17b15ff6701f07377bea8ffd3 (patch)
treee2431be18a85815eb60251a78c4dca13ed5f10fe
parent27a9095aa00426f80660df0e5f857a06852e1496 (diff)
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>
-rw-r--r--drivers/staging/comedi/drivers/unioxx5.c13
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,
474 474
475static void unioxx5_detach(struct comedi_device *dev) 475static void unioxx5_detach(struct comedi_device *dev)
476{ 476{
477 struct comedi_subdevice *s;
478 struct unioxx5_subd_priv *spriv;
477 int i; 479 int i;
478 struct comedi_subdevice *subdev;
479 struct unioxx5_subd_priv *usp;
480 480
481 for (i = 0; i < dev->n_subdevices; i++) { 481 for (i = 0; i < dev->n_subdevices; i++) {
482 subdev = &dev->subdevices[i]; 482 s = &dev->subdevices[i];
483 usp = subdev->private; 483 spriv = s->private;
484 release_region(usp->usp_iobase, UNIOXX5_SIZE); 484 if (spriv && spriv->usp_iobase)
485 kfree(subdev->private); 485 release_region(spriv->usp_iobase, UNIOXX5_SIZE);
486 kfree(spriv);
486 } 487 }
487} 488}
488 489