DPDK patches and discussions
 help / color / mirror / Atom feed
* [PATCH v1 1/1] app/mldev: fix file and buffer handling
@ 2023-09-20  7:09 Srikanth Yalavarthi
  2023-10-04 11:08 ` Anup Prabhu
  2023-10-05  9:13 ` Shivah Shankar Shankar Narayan Rao
  0 siblings, 2 replies; 4+ messages in thread
From: Srikanth Yalavarthi @ 2023-09-20  7:09 UTC (permalink / raw)
  To: Srikanth Yalavarthi; +Cc: dev, sshankarnara, aprabhu, ptakkar, stable

Addressed issues reported by klocwork static analysis tool.

Fixes: fccf444cfe05 ("app/mldev: add function for file read")
Cc: stable@dpdk.org

Signed-off-by: Srikanth Yalavarthi <syalavarthi@marvell.com>
---
 app/test-mldev/test_common.c           | 1 +
 app/test-mldev/test_inference_common.c | 4 ++--
 2 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/app/test-mldev/test_common.c b/app/test-mldev/test_common.c
index 357a85a312..90e591f205 100644
--- a/app/test-mldev/test_common.c
+++ b/app/test-mldev/test_common.c
@@ -34,6 +34,7 @@ ml_read_file(char *file, size_t *size, char **buffer)
 
 	if (fstat(fd, &file_stat) != 0) {
 		ml_err("fstat failed for file: %s\n", file);
+		close(fd);
 		return -errno;
 	}
 
diff --git a/app/test-mldev/test_inference_common.c b/app/test-mldev/test_inference_common.c
index 418bf38be4..05b221401b 100644
--- a/app/test-mldev/test_inference_common.c
+++ b/app/test-mldev/test_inference_common.c
@@ -653,6 +653,7 @@ ml_inference_iomem_setup(struct ml_test *test, struct ml_options *opt, uint16_t
 		ml_err("Invalid input file, size = %zu (expected size = %" PRIu64 ")\n", fsize,
 		       t->model[fid].inp_dsize);
 		ret = -EINVAL;
+		free(buffer);
 		goto error;
 	}
 
@@ -670,6 +671,7 @@ ml_inference_iomem_setup(struct ml_test *test, struct ml_options *opt, uint16_t
 			ml_err("Invalid reference file, size = %zu (expected size = %" PRIu64 ")\n",
 			       fsize, t->model[fid].out_dsize);
 			ret = -EINVAL;
+			free(buffer);
 			goto error;
 		}
 	}
@@ -703,8 +705,6 @@ ml_inference_iomem_setup(struct ml_test *test, struct ml_options *opt, uint16_t
 		t->model[fid].io_pool = NULL;
 	}
 
-	free(buffer);
-
 	return ret;
 }
 
-- 
2.41.0


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

end of thread, other threads:[~2023-11-14 19:36 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-09-20  7:09 [PATCH v1 1/1] app/mldev: fix file and buffer handling Srikanth Yalavarthi
2023-10-04 11:08 ` Anup Prabhu
2023-11-14 19:36   ` Thomas Monjalon
2023-10-05  9:13 ` Shivah Shankar Shankar Narayan Rao

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).