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:
parent
8542373dcc
commit
777e5d3ed5
1 changed files with 1 additions and 0 deletions
|
@ -254,6 +254,7 @@ static int do_dev_config(struct comedi_device *dev, struct comedi_devconfig *it)
|
||||||
if (!devs) {
|
if (!devs) {
|
||||||
dev_err(dev->class_dev,
|
dev_err(dev->class_dev,
|
||||||
"Could not allocate memory. Out of memory?\n");
|
"Could not allocate memory. Out of memory?\n");
|
||||||
|
kfree(bdev);
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
}
|
}
|
||||||
devpriv->devs = devs;
|
devpriv->devs = devs;
|
||||||
|
|
Loading…
Add table
Reference in a new issue