From: Alison Schofield Date: Wed, 27 Jul 2016 03:17:43 +0000 (-0700) Subject: tools: iio: iio_generic_buffer: initialize channel array pointer X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=ddbc719f99cf9aed6918cef98cb3475fd4fc4fa6;p=GitHub%2Fmoto-9609%2Fandroid_kernel_motorola_exynos9610.git tools: iio: iio_generic_buffer: initialize channel array pointer Uninitialized channel pointer causes segmentation fault when we call free(channel) during cleanup() with no channels initialized. This happens when you exit early for usage errors. Initialize the pointer to NULL when it is declared. Signed-off-by: Alison Schofield Cc: Daniel Baluta Tested-by: Gregor Boirie Signed-off-by: Jonathan Cameron --- diff --git a/tools/iio/iio_generic_buffer.c b/tools/iio/iio_generic_buffer.c index 0e8a1f7a292d..ae68bf0e2d51 100644 --- a/tools/iio/iio_generic_buffer.c +++ b/tools/iio/iio_generic_buffer.c @@ -348,7 +348,7 @@ int main(int argc, char **argv) int notrigger = 0; char *dummy; - struct iio_channel_info *channels; + struct iio_channel_info *channels = NULL; register_cleanup();