Linux IIO development
 help / color / mirror / Atom feed
* [PATCH] tools:iio: Fix the potential stack overflow risk
@ 2022-03-24 11:01 jianchunfu
  2022-03-27 14:45 ` Jonathan Cameron
  2022-03-27 22:12 ` Andy Shevchenko
  0 siblings, 2 replies; 3+ messages in thread
From: jianchunfu @ 2022-03-24 11:01 UTC (permalink / raw)
  To: jic23; +Cc: lars, linux-iio, jianchunfu

Add judgment to fix the potential stack overflow risk.

Signed-off-by: jianchunfu <jianchunfu@cmss.chinamobile.com>
---
 tools/iio/iio_generic_buffer.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/tools/iio/iio_generic_buffer.c b/tools/iio/iio_generic_buffer.c
index 2491c54a5..733fc21c2 100644
--- a/tools/iio/iio_generic_buffer.c
+++ b/tools/iio/iio_generic_buffer.c
@@ -487,6 +487,10 @@ int main(int argc, char **argv)
 			return -ENOMEM;
 		}
 		trigger_name = malloc(IIO_MAX_NAME_LENGTH);
+		if (!trigger_name) {
+			ret = -ENOMEM;
+			goto error;
+		}
 		ret = read_sysfs_string("name", trig_dev_name, trigger_name);
 		free(trig_dev_name);
 		if (ret < 0) {
-- 
2.18.4




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

end of thread, other threads:[~2022-03-27 22:13 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-03-24 11:01 [PATCH] tools:iio: Fix the potential stack overflow risk jianchunfu
2022-03-27 14:45 ` Jonathan Cameron
2022-03-27 22:12 ` Andy Shevchenko

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox