]> git.karo-electronics.de Git - linux-beck.git/commitdiff
staging: iio_simple_dummy: fix init function
authorVladimirs Ambrosovs <rodriguez.twister@gmail.com>
Sat, 30 May 2015 08:20:15 +0000 (11:20 +0300)
committerJonathan Cameron <jic23@kernel.org>
Mon, 1 Jun 2015 10:20:19 +0000 (11:20 +0100)
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>
drivers/staging/iio/iio_simple_dummy.c

index b47bf9fb64be02fd2ad7cf4b3f8b428e52cf4999..d0a99637007c40cdc51d9846d98f4792d6acd66b 100644 (file)
@@ -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);