public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] tools/iio/iio_utils:fix memory leak
@ 2023-01-12 11:01 Yulong Zhang
  2023-01-14 16:41 ` Jonathan Cameron
  0 siblings, 1 reply; 6+ messages in thread
From: Yulong Zhang @ 2023-01-12 11:01 UTC (permalink / raw)
  To: linux-iio; +Cc: jic23, lars, linux-kernel, Yulong Zhang

1.fopen sysfsfp without fclose
2.asprintf filename without free

Signed-off-by: Yulong Zhang <yulong.zhang@metoak.net>
---
 tools/iio/iio_utils.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/tools/iio/iio_utils.c b/tools/iio/iio_utils.c
index 8d35893b2..38e9352e5 100644
--- a/tools/iio/iio_utils.c
+++ b/tools/iio/iio_utils.c
@@ -264,6 +264,8 @@ int iioutils_get_param_float(float *output, const char *param_name,
 			if (fscanf(sysfsfp, "%f", output) != 1)
 				ret = errno ? -errno : -ENODATA;
 
+			fclose(sysfsfp);
+
 			break;
 		}
 error_free_filename:
@@ -444,6 +446,7 @@ int build_channel_array(const char *device_dir, int buffer_idx,
 				count--;
 				goto error_cleanup_array;
 			}
+			free(filename);
 
 			ret = asprintf(&filename,
 				       "%s/%s_index",
-- 
2.25.1


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

end of thread, other threads:[~2023-01-21 17:39 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-01-12 11:01 [PATCH] tools/iio/iio_utils:fix memory leak Yulong Zhang
2023-01-14 16:41 ` Jonathan Cameron
2023-01-16  3:30   ` [PATCH v2] " Yulong Zhang
2023-01-16 15:16     ` Jonathan Cameron
2023-01-17  2:51       ` [PATCH v3] " Yulong Zhang
2023-01-21 17:53         ` Jonathan Cameron

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