* iio: dummy_evgen: fix possible memleak in evgen init
@ 2019-04-18 3:02 Pan Bian
2019-04-22 10:46 ` Jonathan Cameron
0 siblings, 1 reply; 2+ messages in thread
From: Pan Bian @ 2019-04-18 3:02 UTC (permalink / raw)
To: Jonathan Cameron, Hartmut Knaack, Lars-Peter Clausen,
Peter Meerwald-Stadler
Cc: linux-iio, linux-kernel, Pan Bian
The memory allocated in the function iio_dummy_evgen_create is not
released if it fails to add the evgen device to device hierarchy. This
may result in a memory leak bug.
Signed-off-by: Pan Bian <bianpan2016@163.com>
---
drivers/iio/dummy/iio_dummy_evgen.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/drivers/iio/dummy/iio_dummy_evgen.c b/drivers/iio/dummy/iio_dummy_evgen.c
index efd0005..f96c0a3 100644
--- a/drivers/iio/dummy/iio_dummy_evgen.c
+++ b/drivers/iio/dummy/iio_dummy_evgen.c
@@ -196,7 +196,10 @@ static __init int iio_dummy_evgen_init(void)
return ret;
device_initialize(&iio_evgen_dev);
dev_set_name(&iio_evgen_dev, "iio_evgen");
- return device_add(&iio_evgen_dev);
+ ret = device_add(&iio_evgen_dev);
+ if (ret)
+ put_device(&iio_evgen_dev);
+ return ret;
}
module_init(iio_dummy_evgen_init);
--
2.7.4
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: iio: dummy_evgen: fix possible memleak in evgen init
2019-04-18 3:02 iio: dummy_evgen: fix possible memleak in evgen init Pan Bian
@ 2019-04-22 10:46 ` Jonathan Cameron
0 siblings, 0 replies; 2+ messages in thread
From: Jonathan Cameron @ 2019-04-22 10:46 UTC (permalink / raw)
To: Pan Bian
Cc: Hartmut Knaack, Lars-Peter Clausen, Peter Meerwald-Stadler,
linux-iio, linux-kernel
On Thu, 18 Apr 2019 11:02:56 +0800
Pan Bian <bianpan2016@163.com> wrote:
> The memory allocated in the function iio_dummy_evgen_create is not
> released if it fails to add the evgen device to device hierarchy. This
> may result in a memory leak bug.
>
> Signed-off-by: Pan Bian <bianpan2016@163.com>
Hi. Not sure why the patch doesn't have the standard [PATCH] prefix
in the title.
This issue has been there a long time, but as the driver is only
a testing stub I'm not going to add a fixes tag or mark it for stable.
That would just be noise I think.
Applied to the togreg branch of iio.git and pushed out as testing
for the autobuilders to play with it.
Thanks,
Jonathan
> ---
> drivers/iio/dummy/iio_dummy_evgen.c | 5 ++++-
> 1 file changed, 4 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/iio/dummy/iio_dummy_evgen.c b/drivers/iio/dummy/iio_dummy_evgen.c
> index efd0005..f96c0a3 100644
> --- a/drivers/iio/dummy/iio_dummy_evgen.c
> +++ b/drivers/iio/dummy/iio_dummy_evgen.c
> @@ -196,7 +196,10 @@ static __init int iio_dummy_evgen_init(void)
> return ret;
> device_initialize(&iio_evgen_dev);
> dev_set_name(&iio_evgen_dev, "iio_evgen");
> - return device_add(&iio_evgen_dev);
> + ret = device_add(&iio_evgen_dev);
> + if (ret)
> + put_device(&iio_evgen_dev);
> + return ret;
> }
> module_init(iio_dummy_evgen_init);
>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2019-04-22 10:46 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-04-18 3:02 iio: dummy_evgen: fix possible memleak in evgen init Pan Bian
2019-04-22 10:46 ` Jonathan Cameron
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox