tools:iio:generic_buffer: fix order of freeing data
authorHartmut Knaack <knaack.h@gmx.de>
Sun, 31 May 2015 12:39:41 +0000 (14:39 +0200)
committerJonathan Cameron <jic23@kernel.org>
Sun, 31 May 2015 16:12:51 +0000 (17:12 +0100)
data gets allocated before buffer_access, so it should be freed in reverse
order. Otherwise, if allocating buffer_access fails, an attempt to free it
would be taken, which should not happen.

Signed-off-by: Hartmut Knaack <knaack.h@gmx.de>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
tools/iio/generic_buffer.c

index f805493be3ebb1097965241baa7be50f045ae67d..15f2a40c9bf730f08bc4943bce07d027acc820cd 100644 (file)
@@ -345,10 +345,10 @@ int main(int argc, char **argv)
 
 error_close_buffer_access:
        close(fp);
-error_free_data:
-       free(data);
 error_free_buffer_access:
        free(buffer_access);
+error_free_data:
+       free(data);
 error_free_buf_dir_name:
        free(buf_dir_name);
 error_free_triggername: