]> git.openfabrics.org - ~emulex/infiniband.git/commitdiff
Staging: comedi: fix memory leak in comedi_bond.c
authorChase Southwood <chase.southwood@yahoo.com>
Sat, 8 Feb 2014 05:02:27 +0000 (23:02 -0600)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 11 Feb 2014 20:22:32 +0000 (12:22 -0800)
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>
drivers/staging/comedi/drivers/comedi_bond.c

index 51a59e5b8ec50db0da8174c990b77718b8ae169b..406aedb5382e9802cd6255da5a824faf02872e3c 100644 (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;