Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit f4362867 authored by H Hartley Sweeten's avatar H Hartley Sweeten Committed by Greg Kroah-Hartman
Browse files

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: default avatarDan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: default avatarH Hartley Sweeten <hsweeten@visionengravers.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent fb868541
Loading
Loading
Loading
Loading
+3 −1
Original line number Original line Diff line number Diff line
@@ -380,8 +380,10 @@ static int __unioxx5_subdev_init(struct comedi_device *dev,
		return -ENOMEM;
		return -ENOMEM;


	ret = __comedi_request_region(dev, iobase, UNIOXX5_SIZE);
	ret = __comedi_request_region(dev, iobase, UNIOXX5_SIZE);
	if (ret)
	if (ret) {
		kfree(usp);
		return ret;
		return ret;
	}
	usp->usp_iobase = iobase;
	usp->usp_iobase = iobase;


	/* defining modules types */
	/* defining modules types */