summaryrefslogtreecommitdiffstats
path: root/tools/iio
diff options
context:
space:
mode:
authorJoo Aun Saw <jasaw@dius.com.au>2015-07-24 11:23:28 -0400
committerJonathan Cameron <jic23@kernel.org>2015-08-08 14:51:39 -0400
commit6b20f40679108e3c04e9bdb3d719e364ec29289e (patch)
tree7559c86e74bccf6b8121cbe604f187e3bcd784da /tools/iio
parentbdb25b0af8bd225ddf82083d767fada56fb2c1ae (diff)
tools: iio: Set caller's ci_array pointer to NULL after free
On error, caller's ci_array is freed and set to NULL to avoid potential double free if some other user of this code is not sufficiently careful. Counter is reset to zero for consistency. Signed-off-by: Joo Aun Saw <jasaw@dius.com.au> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
Diffstat (limited to 'tools/iio')
-rw-r--r--tools/iio/iio_utils.c2
1 files changed, 2 insertions, 0 deletions
diff --git a/tools/iio/iio_utils.c b/tools/iio/iio_utils.c
index 4bbd6e7959cd..8475b832ee39 100644
--- a/tools/iio/iio_utils.c
+++ b/tools/iio/iio_utils.c
@@ -526,6 +526,8 @@ error_cleanup_array:
526 free((*ci_array)[i].generic_name); 526 free((*ci_array)[i].generic_name);
527 } 527 }
528 free(*ci_array); 528 free(*ci_array);
529 *ci_array = NULL;
530 *counter = 0;
529error_close_dir: 531error_close_dir:
530 if (dp) 532 if (dp)
531 if (closedir(dp) == -1) 533 if (closedir(dp) == -1)