Addressed issues reported by klocwork static analysis tool.

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

Signed-off-by: Srikanth Yalavarthi <syalavar...@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

Reply via email to