Staging: comedi: fix memory leak in comedi_bond.c

We allocate bdev and then krealloc the devs pointer in order to add bdev
at the end of the devpriv->devs array list.  But if for some reason this
krealloc fails, we need to free bdev before returning an error otherwise
this memory is leaked.

Signed-off-by: Chase Southwood <chase.southwood@yahoo.com>
Acked-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
Chase Southwood 2014-02-07 23:02:27 -06:00 committed by Greg Kroah-Hartman
parent 8542373dcc
commit 777e5d3ed5

View File

@ -254,6 +254,7 @@ static int do_dev_config(struct comedi_device *dev, struct comedi_devconfig *it)
if (!devs) {
dev_err(dev->class_dev,
"Could not allocate memory. Out of memory?\n");
kfree(bdev);
return -ENOMEM;
}
devpriv->devs = devs;