linux-iio.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] tools: iio: iio_generic_buffer: initialize channel array pointer
@ 2016-07-27  3:17 Alison Schofield
  2016-07-27  8:12 ` Gregor Boirie
  0 siblings, 1 reply; 3+ messages in thread
From: Alison Schofield @ 2016-07-27  3:17 UTC (permalink / raw)
  To: jic23; +Cc: knaack.h, lars, pmeerw, linux-iio, linux-kernel

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>
---
 tools/iio/iio_generic_buffer.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/iio/iio_generic_buffer.c b/tools/iio/iio_generic_buffer.c
index 0e8a1f7..ae68bf0 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();
 
-- 
2.1.4

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] tools: iio: iio_generic_buffer: initialize channel array pointer
  2016-07-27  3:17 [PATCH] tools: iio: iio_generic_buffer: initialize channel array pointer Alison Schofield
@ 2016-07-27  8:12 ` Gregor Boirie
  2016-08-15 16:06   ` Jonathan Cameron
  0 siblings, 1 reply; 3+ messages in thread
From: Gregor Boirie @ 2016-07-27  8:12 UTC (permalink / raw)
  To: Alison Schofield, jic23; +Cc: knaack.h, lars, pmeerw, linux-iio, linux-kernel


On 07/27/2016 05:17 AM, Alison Schofield wrote:
> 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>
> ---
>   tools/iio/iio_generic_buffer.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/tools/iio/iio_generic_buffer.c b/tools/iio/iio_generic_buffer.c
> index 0e8a1f7..ae68bf0 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();
>   
Tested-by: Gregor Boirie <gregor.boirie@parrot.com>

greg.

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] tools: iio: iio_generic_buffer: initialize channel array pointer
  2016-07-27  8:12 ` Gregor Boirie
@ 2016-08-15 16:06   ` Jonathan Cameron
  0 siblings, 0 replies; 3+ messages in thread
From: Jonathan Cameron @ 2016-08-15 16:06 UTC (permalink / raw)
  To: Gregor Boirie, Alison Schofield
  Cc: knaack.h, lars, pmeerw, linux-iio, linux-kernel

On 27/07/16 09:12, Gregor Boirie wrote:
> 
> On 07/27/2016 05:17 AM, Alison Schofield wrote:
>> 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>
>> ---
>>   tools/iio/iio_generic_buffer.c | 2 +-
>>   1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/tools/iio/iio_generic_buffer.c b/tools/iio/iio_generic_buffer.c
>> index 0e8a1f7..ae68bf0 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();
>>   
> Tested-by: Gregor Boirie <gregor.boirie@parrot.com>
I'm not marking this for stable purely because the huge about of
churn in those files makes it tricky to be sure when it first
broke or if it was always broken!

Anyhow, applied to the fixes-togreg branch of iio.git.

Thanks,

Jonathan
> 
> greg.
> -- 
> To unsubscribe from this list: send the line "unsubscribe linux-iio" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2016-08-15 16:07 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-07-27  3:17 [PATCH] tools: iio: iio_generic_buffer: initialize channel array pointer Alison Schofield
2016-07-27  8:12 ` Gregor Boirie
2016-08-15 16:06   ` Jonathan Cameron

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).