提交 7f5ac6f4 编写于 作者: H H Hartley Sweeten 提交者: Greg Kroah-Hartman

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: NH Hartley Sweeten <hsweeten@visionengravers.com>
Cc: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
上级 27a9095a
...@@ -474,15 +474,16 @@ static int unioxx5_attach(struct comedi_device *dev, ...@@ -474,15 +474,16 @@ static int unioxx5_attach(struct comedi_device *dev,
static void unioxx5_detach(struct comedi_device *dev) static void unioxx5_detach(struct comedi_device *dev)
{ {
struct comedi_subdevice *s;
struct unioxx5_subd_priv *spriv;
int i; int i;
struct comedi_subdevice *subdev;
struct unioxx5_subd_priv *usp;
for (i = 0; i < dev->n_subdevices; i++) { for (i = 0; i < dev->n_subdevices; i++) {
subdev = &dev->subdevices[i]; s = &dev->subdevices[i];
usp = subdev->private; spriv = s->private;
release_region(usp->usp_iobase, UNIOXX5_SIZE); if (spriv && spriv->usp_iobase)
kfree(subdev->private); release_region(spriv->usp_iobase, UNIOXX5_SIZE);
kfree(spriv);
} }
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册