[v1,1/1] app/mldev: fix file and buffer handling
Checks
Commit Message
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(-)
Comments
> -----Original Message-----
> From: Srikanth Yalavarthi <syalavarthi@marvell.com>
> Sent: Wednesday, September 20, 2023 12:40 PM
> To: Srikanth Yalavarthi <syalavarthi@marvell.com>
> Cc: dev@dpdk.org; Shivah Shankar Shankar Narayan Rao
> <sshankarnara@marvell.com>; Anup Prabhu <aprabhu@marvell.com>;
> Prince Takkar <ptakkar@marvell.com>; stable@dpdk.org
> Subject: [PATCH v1 1/1] app/mldev: fix file and buffer handling
>
> 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>
Acked-by: Anup Prabhu <aprabhu@marvell.com>
> -----Original Message-----
> From: Srikanth Yalavarthi <syalavarthi@marvell.com>
> Sent: Wednesday, September 20, 2023 12:40 PM
> To: Srikanth Yalavarthi <syalavarthi@marvell.com>
> Cc: dev@dpdk.org; Shivah Shankar Shankar Narayan Rao
> <sshankarnara@marvell.com>; Anup Prabhu <aprabhu@marvell.com>;
> Prince Takkar <ptakkar@marvell.com>; stable@dpdk.org
> Subject: [PATCH v1 1/1] app/mldev: fix file and buffer handling
>
> 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>
Acked-by: Shivah Shankar S <sshankarnara@marvell.com>
04/10/2023 13:08, Anup Prabhu:
> From: Srikanth Yalavarthi <syalavarthi@marvell.com>
> >
> > 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>
> Acked-by: Anup Prabhu <aprabhu@marvell.com>
Applied, thanks.
@@ -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;
}
@@ -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;
}