From: Joo Aun Saw Date: Fri, 24 Jul 2015 15:23:28 +0000 (+1000) Subject: tools: iio: Set caller's ci_array pointer to NULL after free X-Git-Tag: v4.3-rc1~158^2~139^2~6 X-Git-Url: https://git.karo-electronics.de/?a=commitdiff_plain;h=6b20f40679108e3c04e9bdb3d719e364ec29289e;p=karo-tx-linux.git 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 Signed-off-by: Jonathan Cameron --- 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: free((*ci_array)[i].generic_name); } free(*ci_array); + *ci_array = NULL; + *counter = 0; error_close_dir: if (dp) if (closedir(dp) == -1)