Skip to content

Commit

Permalink
tools: iio: iio_generic_buffer: initialize channel array pointer
Browse files Browse the repository at this point in the history
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 <amsfield22@gmail.com>
Cc: Daniel Baluta <daniel.baluta@gmail.com>
Tested-by: Gregor Boirie <gregor.boirie@parrot.com>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
  • Loading branch information
Alison Schofield authored and Jonathan Cameron committed Aug 15, 2016
1 parent 0d9dcf8 commit ddbc719
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion tools/iio/iio_generic_buffer.c
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand Down

0 comments on commit ddbc719

Please sign in to comment.