summaryrefslogtreecommitdiff
path: root/drivers/staging/iio
diff options
context:
space:
mode:
authorVladimirs Ambrosovs <rodriguez.twister@gmail.com>2015-05-30 11:20:15 +0300
committerJonathan Cameron <jic23@kernel.org>2015-06-01 13:20:19 +0300
commitb3f6af36e52e1e61cf7571c77dba0e905c38297a (patch)
treed3a1638a5482da0b0a614acd5dea61cd9b97bed4 /drivers/staging/iio
parentff7d4f5981a8a139ead70adef3c1d0ed574bca01 (diff)
downloadlinux-b3f6af36e52e1e61cf7571c77dba0e905c38297a.tar.xz
staging: iio_simple_dummy: fix init function
This patch fixes the init function for the iio_simple_dummy driver. The main issues were absence of kfree for the allocated array, and no devices being removed in case the probe function fails, running in a loop. Signed-off-by: Vladimirs Ambrosovs <rodriguez.twister@gmail.com> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
Diffstat (limited to 'drivers/staging/iio')
-rw-r--r--drivers/staging/iio/iio_simple_dummy.c9
1 files changed, 8 insertions, 1 deletions
diff --git a/drivers/staging/iio/iio_simple_dummy.c b/drivers/staging/iio/iio_simple_dummy.c
index b47bf9fb64be..d0a99637007c 100644
--- a/drivers/staging/iio/iio_simple_dummy.c
+++ b/drivers/staging/iio/iio_simple_dummy.c
@@ -722,9 +722,16 @@ static __init int iio_dummy_init(void)
for (i = 0; i < instances; i++) {
ret = iio_dummy_probe(i);
if (ret < 0)
- return ret;
+ goto error_remove_devs;
}
return 0;
+
+error_remove_devs:
+ while (i--)
+ iio_dummy_remove(i);
+
+ kfree(iio_dummy_devs);
+ return ret;
}
module_init(iio_dummy_init);