DPDK patches and discussions
 help / color / mirror / Atom feed
* [PATCH v1] app/testpmd: fix dereference before null check
@ 2021-12-09 16:27 Sean Morrissey
  2022-01-18  9:59 ` Ferruh Yigit
  2022-01-18 10:53 ` [PATCH v2] " Sean Morrissey
  0 siblings, 2 replies; 4+ messages in thread
From: Sean Morrissey @ 2021-12-09 16:27 UTC (permalink / raw)
  To: Ori Kam, Xiaoyun Li, Aman Singh; +Cc: dev, Sean Morrissey, stable, wei.zhao1

Assign 'left' variable only after null check on 'size'
as function returns if 'size' is null.

Coverity issue: 374381
Fixes: 169a9fed1f4 ("app/testpmd: fix hex string parser support for flow API")
Cc: stable@dpdk.org
Cc: wei.zhao1@intel.com

Signed-off-by: Sean Morrissey <sean.morrissey@intel.com>
---
 app/test-pmd/cmdline_flow.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/app/test-pmd/cmdline_flow.c b/app/test-pmd/cmdline_flow.c
index bbe3dc0115..5bb7abcced 100644
--- a/app/test-pmd/cmdline_flow.c
+++ b/app/test-pmd/cmdline_flow.c
@@ -7702,7 +7702,6 @@ parse_string(struct context *ctx, const struct token *token,
 static int
 parse_hex_string(const char *src, uint8_t *dst, uint32_t *size)
 {
-	uint32_t left = *size;
 	const uint8_t *head = dst;
 
 	/* Check input parameters */
@@ -7712,6 +7711,8 @@ parse_hex_string(const char *src, uint8_t *dst, uint32_t *size)
 		(*size == 0))
 		return -1;
 
+	uint32_t left = *size;
+
 	/* Convert chars to bytes */
 	while (left) {
 		char tmp[3], *end = tmp;
-- 
2.25.1


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

* Re: [PATCH v1] app/testpmd: fix dereference before null check
  2021-12-09 16:27 [PATCH v1] app/testpmd: fix dereference before null check Sean Morrissey
@ 2022-01-18  9:59 ` Ferruh Yigit
  2022-01-18 10:53 ` [PATCH v2] " Sean Morrissey
  1 sibling, 0 replies; 4+ messages in thread
From: Ferruh Yigit @ 2022-01-18  9:59 UTC (permalink / raw)
  To: Sean Morrissey, Ori Kam, Xiaoyun Li, Aman Singh; +Cc: dev, stable, wei.zhao1

On 12/9/2021 4:27 PM, Sean Morrissey wrote:
> Assign 'left' variable only after null check on 'size'
> as function returns if 'size' is null.
> 
> Coverity issue: 374381
> Fixes: 169a9fed1f4 ("app/testpmd: fix hex string parser support for flow API")
> Cc: stable@dpdk.org
> Cc: wei.zhao1@intel.com
> 
> Signed-off-by: Sean Morrissey <sean.morrissey@intel.com>
> ---
>   app/test-pmd/cmdline_flow.c | 3 ++-
>   1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/app/test-pmd/cmdline_flow.c b/app/test-pmd/cmdline_flow.c
> index bbe3dc0115..5bb7abcced 100644
> --- a/app/test-pmd/cmdline_flow.c
> +++ b/app/test-pmd/cmdline_flow.c
> @@ -7702,7 +7702,6 @@ parse_string(struct context *ctx, const struct token *token,
>   static int
>   parse_hex_string(const char *src, uint8_t *dst, uint32_t *size)
>   {
> -	uint32_t left = *size;
>   	const uint8_t *head = dst;
>   
>   	/* Check input parameters */
> @@ -7712,6 +7711,8 @@ parse_hex_string(const char *src, uint8_t *dst, uint32_t *size)
>   		(*size == 0))
>   		return -1;
>   
> +	uint32_t left = *size;
> +

Hi Sean,

Change looks good but can you please move variable declaration to the beginning
of the scope, like:

   uint32_t left;

   <null checks>

   left = *size;


With above change,
Reviewed-by: Ferruh Yigit <ferruh.yigit@intel.com>

Please keep the tag in next version.

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

* [PATCH v2] app/testpmd: fix dereference before null check
  2021-12-09 16:27 [PATCH v1] app/testpmd: fix dereference before null check Sean Morrissey
  2022-01-18  9:59 ` Ferruh Yigit
@ 2022-01-18 10:53 ` Sean Morrissey
  2022-01-18 13:28   ` Ferruh Yigit
  1 sibling, 1 reply; 4+ messages in thread
From: Sean Morrissey @ 2022-01-18 10:53 UTC (permalink / raw)
  To: Ori Kam, Xiaoyun Li, Aman Singh, Yuying Zhang
  Cc: dev, Sean Morrissey, stable, wei.zhao1, Ferruh Yigit

Assign 'left' variable only after null check on 'size'
as function returns if 'size' is null.

Coverity issue: 374381
Fixes: 169a9fed1f4 ("app/testpmd: fix hex string parser support for flow API")
Cc: stable@dpdk.org
Cc: wei.zhao1@intel.com

Signed-off-by: Sean Morrissey <sean.morrissey@intel.com>

Reviewed-by: Ferruh Yigit <ferruh.yigit@intel.com>
---
 app/test-pmd/cmdline_flow.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/app/test-pmd/cmdline_flow.c b/app/test-pmd/cmdline_flow.c
index 5c2bba48ad..bbaf18d76e 100644
--- a/app/test-pmd/cmdline_flow.c
+++ b/app/test-pmd/cmdline_flow.c
@@ -7702,8 +7702,8 @@ parse_string(struct context *ctx, const struct token *token,
 static int
 parse_hex_string(const char *src, uint8_t *dst, uint32_t *size)
 {
-	uint32_t left = *size;
 	const uint8_t *head = dst;
+	uint32_t left;
 
 	/* Check input parameters */
 	if ((src == NULL) ||
@@ -7712,6 +7712,8 @@ parse_hex_string(const char *src, uint8_t *dst, uint32_t *size)
 		(*size == 0))
 		return -1;
 
+	left = *size;
+
 	/* Convert chars to bytes */
 	while (left) {
 		char tmp[3], *end = tmp;
-- 
2.25.1


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

* Re: [PATCH v2] app/testpmd: fix dereference before null check
  2022-01-18 10:53 ` [PATCH v2] " Sean Morrissey
@ 2022-01-18 13:28   ` Ferruh Yigit
  0 siblings, 0 replies; 4+ messages in thread
From: Ferruh Yigit @ 2022-01-18 13:28 UTC (permalink / raw)
  To: Sean Morrissey, Ori Kam, Xiaoyun Li, Aman Singh, Yuying Zhang
  Cc: dev, stable, wei.zhao1

On 1/18/2022 10:53 AM, Sean Morrissey wrote:
> Assign 'left' variable only after null check on 'size'
> as function returns if 'size' is null.
> 
> Coverity issue: 374381
> Fixes: 169a9fed1f4 ("app/testpmd: fix hex string parser support for flow API")
> Cc: stable@dpdk.org
> Cc: wei.zhao1@intel.com
> 
> Signed-off-by: Sean Morrissey <sean.morrissey@intel.com>
> Reviewed-by: Ferruh Yigit <ferruh.yigit@intel.com>

Applied to dpdk-next-net/main, thanks.

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

end of thread, other threads:[~2022-01-18 13:28 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-12-09 16:27 [PATCH v1] app/testpmd: fix dereference before null check Sean Morrissey
2022-01-18  9:59 ` Ferruh Yigit
2022-01-18 10:53 ` [PATCH v2] " Sean Morrissey
2022-01-18 13:28   ` Ferruh Yigit

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