Skip to content

Commit

Permalink
staging: comedi: unionxx5: fix memory leak during subdevice init
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
H Hartley Sweeten authored and Greg Kroah-Hartman committed Apr 17, 2013
1 parent fb86854 commit f436286
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion drivers/staging/comedi/drivers/unioxx5.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand Down

0 comments on commit f436286

Please sign in to comment.