app/test-compress-perf: fix improper use of negative value

Message ID 1558358764-32053-1-git-send-email-tomaszx.jozwiak@intel.com (mailing list archive)
State Accepted, archived
Delegated to: akhil goyal
Headers
Series app/test-compress-perf: fix improper use of negative value |

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/mellanox-Performance-Testing success Performance Testing PASS
ci/intel-Performance-Testing success Performance Testing PASS
ci/Intel-compilation success Compilation OK

Commit Message

Tomasz Jozwiak May 20, 2019, 1:26 p.m. UTC
  This patch fixes coverity issue: Improper use of negative value.
test_data->input_data_sz is passed to a parameter that
cannot be negative.

Coverity issue: 328504
Fixes: b68a82425da4 ("app/compress-perf: add performance measurement")
Cc: stable@dpdk.org

Signed-off-by: Tomasz Jozwiak <tomaszx.jozwiak@intel.com>
---
 app/test-compress-perf/main.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
  

Comments

Fiona Trahe May 20, 2019, 1:39 p.m. UTC | #1
> -----Original Message-----
> From: Jozwiak, TomaszX
> Sent: Monday, May 20, 2019 2:26 PM
> To: dev@dpdk.org; Trahe, Fiona <fiona.trahe@intel.com>; Jozwiak, TomaszX
> <tomaszx.jozwiak@intel.com>; shallyv@marvell.com; stable@dpdk.org
> Subject: [PATCH] app/test-compress-perf: fix improper use of negative value
> 
> This patch fixes coverity issue: Improper use of negative value.
> test_data->input_data_sz is passed to a parameter that
> cannot be negative.
> 
> Coverity issue: 328504
> Fixes: b68a82425da4 ("app/compress-perf: add performance measurement")
> Cc: stable@dpdk.org
> 
> Signed-off-by: Tomasz Jozwiak <tomaszx.jozwiak@intel.com>
Acked-by: Fiona Trahe <fiona.trahe@intel.com>
  
Akhil Goyal June 19, 2019, 2:55 p.m. UTC | #2
> >
> > This patch fixes coverity issue: Improper use of negative value.
> > test_data->input_data_sz is passed to a parameter that
> > cannot be negative.
> >
> > Coverity issue: 328504
> > Fixes: b68a82425da4 ("app/compress-perf: add performance measurement")
> > Cc: stable@dpdk.org
> >
> > Signed-off-by: Tomasz Jozwiak <tomaszx.jozwiak@intel.com>
> Acked-by: Fiona Trahe <fiona.trahe@intel.com>

Applied to dpdk-next-crypto

Thanks
  

Patch

diff --git a/app/test-compress-perf/main.c b/app/test-compress-perf/main.c
index c2a45d1..5a579ea 100644
--- a/app/test-compress-perf/main.c
+++ b/app/test-compress-perf/main.c
@@ -244,7 +244,8 @@  comp_perf_dump_input_data(struct comp_test_data *test_data)
 	if (test_data->input_data_sz == 0)
 		test_data->input_data_sz = actual_file_sz;
 
-	if (fseek(f, 0, SEEK_SET) != 0) {
+	if (test_data->input_data_sz <= 0 || actual_file_sz <= 0 ||
+			fseek(f, 0, SEEK_SET) != 0) {
 		RTE_LOG(ERR, USER1, "Size of input could not be calculated\n");
 		goto end;
 	}