diff mbox series

[4/5] tools: PCI: Fix memory leak

Message ID 20220819145018.35732-5-manivannan.sadhasivam@linaro.org
State New
Headers show
Series pci_endpoint_test: Fix the return value of IOCTLs | expand

Commit Message

Manivannan Sadhasivam Aug. 19, 2022, 2:50 p.m. UTC
Memory allocated for "test" needs to be freed at the end of the main().

Signed-off-by: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
---
 tools/pci/pcitest.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)
diff mbox series

Patch

diff --git a/tools/pci/pcitest.c b/tools/pci/pcitest.c
index a4e5b17cc3b5..a416a66802f3 100644
--- a/tools/pci/pcitest.c
+++ b/tools/pci/pcitest.c
@@ -157,7 +157,7 @@  static int run_test(struct pci_test *test)
 
 int main(int argc, char **argv)
 {
-	int c;
+	int c, ret;
 	struct pci_test *test;
 
 	test = calloc(1, sizeof(*test));
@@ -249,5 +249,8 @@  int main(int argc, char **argv)
 		return -EINVAL;
 	}
 
-	return run_test(test);
+	ret = run_test(test);
+	free(test);
+
+	return ret;
 }