summaryrefslogtreecommitdiffstats
path: root/drivers/iio/dummy
diff options
context:
space:
mode:
authorPan Bian <bianpan2016@163.com>2019-04-18 05:02:56 +0200
committerJonathan Cameron <Jonathan.Cameron@huawei.com>2019-04-22 12:45:03 +0200
commitdfd4f6497614ccb34f822849dd2e1fd2c44de37f (patch)
tree4cc3956c8cbcd3f6f8f089bf5f3b76a9eff364a4 /drivers/iio/dummy
parentiio:accel:Switch hardcoded function name with a reference to __func__ making ... (diff)
downloadlinux-dfd4f6497614ccb34f822849dd2e1fd2c44de37f.tar.xz
linux-dfd4f6497614ccb34f822849dd2e1fd2c44de37f.zip
iio: dummy_evgen: fix possible memleak in evgen init
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> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Diffstat (limited to 'drivers/iio/dummy')
-rw-r--r--drivers/iio/dummy/iio_dummy_evgen.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/drivers/iio/dummy/iio_dummy_evgen.c b/drivers/iio/dummy/iio_dummy_evgen.c
index efd0005f59b4..c6033e341963 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);