* [PATCH] Staging: comedi: fix memory leak in comedi_bond.c
@ 2014-02-08 5:02 Chase Southwood
2014-02-10 12:52 ` Ian Abbott
0 siblings, 1 reply; 2+ messages in thread
From: Chase Southwood @ 2014-02-08 5:02 UTC (permalink / raw)
To: gregkh; +Cc: abbotti, hsweeten, linux-kernel, devel, Chase Southwood
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>
---
drivers/staging/comedi/drivers/comedi_bond.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/drivers/staging/comedi/drivers/comedi_bond.c b/drivers/staging/comedi/drivers/comedi_bond.c
index 51a59e5..406aedb 100644
--- a/drivers/staging/comedi/drivers/comedi_bond.c
+++ b/drivers/staging/comedi/drivers/comedi_bond.c
@@ -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;
--
1.8.5.3
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] Staging: comedi: fix memory leak in comedi_bond.c
2014-02-08 5:02 [PATCH] Staging: comedi: fix memory leak in comedi_bond.c Chase Southwood
@ 2014-02-10 12:52 ` Ian Abbott
0 siblings, 0 replies; 2+ messages in thread
From: Ian Abbott @ 2014-02-10 12:52 UTC (permalink / raw)
To: Chase Southwood, gregkh@linuxfoundation.org
Cc: Ian Abbott, hsweeten@visionengravers.com,
linux-kernel@vger.kernel.org, devel@driverdev.osuosl.org
On 2014-02-08 05:02, Chase Southwood wrote:
> 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>
> ---
> drivers/staging/comedi/drivers/comedi_bond.c | 1 +
> 1 file changed, 1 insertion(+)
>
> diff --git a/drivers/staging/comedi/drivers/comedi_bond.c b/drivers/staging/comedi/drivers/comedi_bond.c
> index 51a59e5..406aedb 100644
> --- a/drivers/staging/comedi/drivers/comedi_bond.c
> +++ b/drivers/staging/comedi/drivers/comedi_bond.c
> @@ -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;
>
Acked-by: Ian Abbott <abbotti@mev.co.uk>
--
-=( Ian Abbott @ MEV Ltd. E-mail: <abbotti@mev.co.uk> )=-
-=( Tel: +44 (0)161 477 1898 FAX: +44 (0)161 718 3587 )=-
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2014-02-10 12:52 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-02-08 5:02 [PATCH] Staging: comedi: fix memory leak in comedi_bond.c Chase Southwood
2014-02-10 12:52 ` Ian Abbott
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox