From: Srikanth Yalavarthi <syalavarthi@marvell.com>
To: Srikanth Yalavarthi <syalavarthi@marvell.com>
Cc: <dev@dpdk.org>, <sshankarnara@marvell.com>, <aprabhu@marvell.com>,
<ptakkar@marvell.com>, <stable@dpdk.org>
Subject: [PATCH v1 1/1] app/mldev: fix file and buffer handling
Date: Wed, 20 Sep 2023 00:09:41 -0700 [thread overview]
Message-ID: <20230920070941.8626-1-syalavarthi@marvell.com> (raw)
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
next reply other threads:[~2023-09-20 7:09 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-09-20 7:09 Srikanth Yalavarthi [this message]
2023-10-04 11:08 ` Anup Prabhu
2023-11-14 19:36 ` Thomas Monjalon
2023-10-05 9:13 ` Shivah Shankar Shankar Narayan Rao
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230920070941.8626-1-syalavarthi@marvell.com \
--to=syalavarthi@marvell.com \
--cc=aprabhu@marvell.com \
--cc=dev@dpdk.org \
--cc=ptakkar@marvell.com \
--cc=sshankarnara@marvell.com \
--cc=stable@dpdk.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).