DPDK patches and discussions
 help / color / mirror / Atom feed
* [PATCH] app/testpmd: remove useless pointer checks
@ 2022-03-24 16:15 David Marchand
  2022-03-29  9:26 ` Thomas Monjalon
  0 siblings, 1 reply; 4+ messages in thread
From: David Marchand @ 2022-03-24 16:15 UTC (permalink / raw)
  To: dev
  Cc: stable, Ori Kam, Xiaoyun Li, Aman Singh, Yuying Zhang,
	Ferruh Yigit, Wei Zhao

Parameters to this static helper can't be NULL.
str has already been dereferenced in caller.
dst and size point to variable in stack.

Fixes: 169a9fed1f4c ("app/testpmd: fix hex string parser support for flow API")
Cc: stable@dpdk.org

Signed-off-by: David Marchand <david.marchand@redhat.com>
---
 app/test-pmd/cmdline_flow.c | 6 +-----
 1 file changed, 1 insertion(+), 5 deletions(-)

diff --git a/app/test-pmd/cmdline_flow.c b/app/test-pmd/cmdline_flow.c
index fc4a6d9cca..e3269e278d 100644
--- a/app/test-pmd/cmdline_flow.c
+++ b/app/test-pmd/cmdline_flow.c
@@ -9338,11 +9338,7 @@ parse_hex_string(const char *src, uint8_t *dst, uint32_t *size)
 	const uint8_t *head = dst;
 	uint32_t left;
 
-	/* Check input parameters */
-	if ((src == NULL) ||
-		(dst == NULL) ||
-		(size == NULL) ||
-		(*size == 0))
+	if (*size == 0)
 		return -1;
 
 	left = *size;
-- 
2.23.0


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

* Re: [PATCH] app/testpmd: remove useless pointer checks
  2022-03-24 16:15 [PATCH] app/testpmd: remove useless pointer checks David Marchand
@ 2022-03-29  9:26 ` Thomas Monjalon
  2022-05-12  7:19   ` David Marchand
  0 siblings, 1 reply; 4+ messages in thread
From: Thomas Monjalon @ 2022-03-29  9:26 UTC (permalink / raw)
  To: David Marchand
  Cc: dev, stable, Ori Kam, Xiaoyun Li, Aman Singh, Yuying Zhang,
	Ferruh Yigit, Wei Zhao

24/03/2022 17:15, David Marchand:
> Parameters to this static helper can't be NULL.
> str has already been dereferenced in caller.
> dst and size point to variable in stack.

The same function is copy/pasted in several places.
Why simplifying only this one? because of its static nature?

Shouldn't we make it a common function as other string helpers?




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

* Re: [PATCH] app/testpmd: remove useless pointer checks
  2022-03-29  9:26 ` Thomas Monjalon
@ 2022-05-12  7:19   ` David Marchand
  2022-05-20 15:04     ` Ferruh Yigit
  0 siblings, 1 reply; 4+ messages in thread
From: David Marchand @ 2022-05-12  7:19 UTC (permalink / raw)
  To: Thomas Monjalon
  Cc: dev, dpdk stable, Ori Kam, Xiaoyun Li, Aman Singh, Yuying Zhang,
	Ferruh Yigit, Wei Zhao

On Tue, Mar 29, 2022 at 11:26 AM Thomas Monjalon <thomas@monjalon.net> wrote:
>
> 24/03/2022 17:15, David Marchand:
> > Parameters to this static helper can't be NULL.
> > str has already been dereferenced in caller.
> > dst and size point to variable in stack.
>
> The same function is copy/pasted in several places.
> Why simplifying only this one? because of its static nature?
>
> Shouldn't we make it a common function as other string helpers?

Sorry, this thread fell through the cracks.

The issue was raised by covscan:

Error: REVERSE_INULL (CWE-476):
dpdk-21.11/app/test-pmd/cmdline_flow.c:7705: deref_ptr: Directly
dereferencing pointer "size".
dpdk-21.11/app/test-pmd/cmdline_flow.c:7711: check_after_deref:
Null-checking "size" suggests that it may be null, but it has already
been dereferenced on all paths leading to the check.
# 7709|       if ((src == NULL) ||
# 7710|           (dst == NULL) ||
# 7711|->         (size == NULL) ||
# 7712|           (*size == 0))
# 7713|           return -1;


As for the rest of the code, there might be more cleanups to do, as followups.


-- 
David Marchand


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

* Re: [PATCH] app/testpmd: remove useless pointer checks
  2022-05-12  7:19   ` David Marchand
@ 2022-05-20 15:04     ` Ferruh Yigit
  0 siblings, 0 replies; 4+ messages in thread
From: Ferruh Yigit @ 2022-05-20 15:04 UTC (permalink / raw)
  To: David Marchand, Thomas Monjalon
  Cc: dev, dpdk stable, Ori Kam, Xiaoyun Li, Aman Singh, Yuying Zhang,
	Wei Zhao

On 5/12/2022 8:19 AM, David Marchand wrote:
> On Tue, Mar 29, 2022 at 11:26 AM Thomas Monjalon <thomas@monjalon.net> wrote:
>>
>> 24/03/2022 17:15, David Marchand:
>>> Parameters to this static helper can't be NULL.
>>> str has already been dereferenced in caller.
>>> dst and size point to variable in stack.
>>
>> The same function is copy/pasted in several places.
>> Why simplifying only this one? because of its static nature?
>>
>> Shouldn't we make it a common function as other string helpers?
> 
> Sorry, this thread fell through the cracks.
> 
> The issue was raised by covscan:
> 
> Error: REVERSE_INULL (CWE-476):
> dpdk-21.11/app/test-pmd/cmdline_flow.c:7705: deref_ptr: Directly
> dereferencing pointer "size".
> dpdk-21.11/app/test-pmd/cmdline_flow.c:7711: check_after_deref:
> Null-checking "size" suggests that it may be null, but it has already
> been dereferenced on all paths leading to the check.
> # 7709|       if ((src == NULL) ||
> # 7710|           (dst == NULL) ||
> # 7711|->         (size == NULL) ||
> # 7712|           (*size == 0))
> # 7713|           return -1;
> 
> 
> As for the rest of the code, there might be more cleanups to do, as followups.
> 

Proceeding with this one as it solves coverity issue,

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

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

end of thread, other threads:[~2022-05-20 15:04 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-03-24 16:15 [PATCH] app/testpmd: remove useless pointer checks David Marchand
2022-03-29  9:26 ` Thomas Monjalon
2022-05-12  7:19   ` David Marchand
2022-05-20 15:04     ` Ferruh Yigit

DPDK patches and discussions

This inbox may be cloned and mirrored by anyone:

	git clone --mirror http://inbox.dpdk.org/dev/0 dev/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 dev dev/ http://inbox.dpdk.org/dev \
		dev@dpdk.org
	public-inbox-index dev

Example config snippet for mirrors.
Newsgroup available over NNTP:
	nntp://inbox.dpdk.org/inbox.dpdk.dev


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git