diff options
author | Hartmut Knaack <knaack.h@gmx.de> | 2015-05-31 12:39:44 (GMT) |
---|---|---|
committer | Jonathan Cameron <jic23@kernel.org> | 2015-05-31 16:20:16 (GMT) |
commit | 63f05c855f3825b89b92cd21df0415e6e32af3dd (patch) | |
tree | d798e25a74fd44dad2c3311b88ffd42cd55d1bf8 /tools/iio/generic_buffer.c | |
parent | 66dd08fde06e5ad6f0f86c7a780d60973e9d9cf0 (diff) | |
download | linux-63f05c855f3825b89b92cd21df0415e6e32af3dd.tar.xz |
tools:iio: free channel-array completely
In iio_utils.c build_channel_array() dynamically allocates the string
generic_name in the current iio_channel_info, which doesn't got freed in
case of an error.
This dynamically allocated channel-array is used by generic_buffer, and
needs to be freed on the error/exit path.
Signed-off-by: Hartmut Knaack <knaack.h@gmx.de>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
Diffstat (limited to 'tools/iio/generic_buffer.c')
-rw-r--r-- | tools/iio/generic_buffer.c | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/tools/iio/generic_buffer.c b/tools/iio/generic_buffer.c index 7859ee9..0410948 100644 --- a/tools/iio/generic_buffer.c +++ b/tools/iio/generic_buffer.c @@ -255,7 +255,7 @@ int main(int argc, char **argv) "%siio:device%d/buffer", iio_dir, dev_num); if (ret < 0) { ret = -ENOMEM; - goto error_free_triggername; + goto error_free_channels; } if (!notrigger) { @@ -351,6 +351,12 @@ error_free_data: free(data); error_free_buf_dir_name: free(buf_dir_name); +error_free_channels: + for (i = num_channels - 1; i >= 0; i--) { + free(channels[i].name); + free(channels[i].generic_name); + } + free(channels); error_free_triggername: if (datardytrigger) free(trigger_name); |