staging: comedi: unionxx5: fix memory leak during subdevice init

In the subdevice init during the attach of this driver, private data
is allocated for each subdevice. The pointer to this data is then
saved in the subdevice 's->private' so it can be free'ed during the
detach.

In __unioxx5_subdev_init() an error path exists that can happen before
the allocated pointer is saved in s->private. Make sure the allocated
memory is free'ed before returning the error.

Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
H Hartley Sweeten 2013-04-15 10:19:07 -07:00 committed by Greg Kroah-Hartman
parent fb86854109
commit f4362867e0
1 changed files with 3 additions and 1 deletions

View File

@ -380,8 +380,10 @@ static int __unioxx5_subdev_init(struct comedi_device *dev,
return -ENOMEM;
ret = __comedi_request_region(dev, iobase, UNIOXX5_SIZE);
if (ret)
if (ret) {
kfree(usp);
return ret;
}
usp->usp_iobase = iobase;
/* defining modules types */