Skip to contentSkip to conversation

tools: iio: iio_generic_buffer: initialize channel array pointer

PATCH In review Alison Schofield 3 participants 3 messages Jul 27, 2016 – Aug 15, 2016 IIO

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 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.

---
 tools/iio/iio_generic_buffer.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tools/iio/iio_generic_buffer.c +1 -1
index 0e8a1f7..ae68bf0 100644
@@ -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();
 
Signature · 1 line
2.1.4
Tested-by on v1 1/1
#1 lore raw
Quoted 16 lines · Alison Schofield

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.

---
  tools/iio/iio_generic_buffer.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
tools/iio/iio_generic_buffer.c +0 -0
index 0e8a1f7..ae68bf0 100644

tools/iio/iio_generic_buffer.c int main(int argc, char **argv) · line 354

Quoted 8 lines
tools/iio/iio_generic_buffer.c +1 -1
@@ -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();
 

greg.

maintainer
#2 lore raw
Quoted 13 lines · Gregor Boirie
Quoted 11 lines · Alison Schofield

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.

---
  tools/iio/iio_generic_buffer.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
Quoted 12 lines

tools/iio/iio_generic_buffer.c int main(int argc, char **argv) · line 353

Quoted 11 lines
tools/iio/iio_generic_buffer.c +1 -0
index 0e8a1f7..ae68bf0 100644
@@ -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();
 

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

Quoted 6 lines

greg.

Signature · 3 lines
To unsubscribe from this list: send the line "unsubscribe linux-iio" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html