patches for DPDK stable branches
 help / color / mirror / Atom feed
* [PATCH] devargs: fix derefrence before null test
@ 2023-10-30 11:45 Weiguo Li
  2023-10-30 16:24 ` Stephen Hemminger
  0 siblings, 1 reply; 2+ messages in thread
From: Weiguo Li @ 2023-10-30 11:45 UTC (permalink / raw)
  To: dev; +Cc: stable, Weiguo Li

Pointer 'da' was dereferenced and then compared to NULL,
reorder the code to keep the logic consistent.

Fixes: 4969f5914c9e ("devargs: introduce new parsing helper")
Cc: stable@dpdk.org

Signed-off-by: Weiguo Li <liweiguo@xencore.cn>
---
 .mailmap                            | 2 +-
 lib/eal/common/eal_common_devargs.c | 4 +++-
 2 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/.mailmap b/.mailmap
index 3f5bab26a8..b4f0ae26b8 100644
--- a/.mailmap
+++ b/.mailmap
@@ -1500,7 +1500,7 @@ Waterman Cao <waterman.cao@intel.com>
 Weichun Chen <weichunx.chen@intel.com>
 Wei Dai <wei.dai@intel.com>
 Weifeng Li <liweifeng96@126.com>
-Weiguo Li <liwg06@foxmail.com>
+Weiguo Li <liwg06@foxmail.com> <liweiguo@xencore.cn>
 Wei Huang <wei.huang@intel.com>
 Wei Hu <weh@microsoft.com>
 Wei Hu (Xavier) <xavier.huwei@huawei.com>
diff --git a/lib/eal/common/eal_common_devargs.c b/lib/eal/common/eal_common_devargs.c
index fb5d0a293b..8d6c3938eb 100644
--- a/lib/eal/common/eal_common_devargs.c
+++ b/lib/eal/common/eal_common_devargs.c
@@ -185,11 +185,13 @@ rte_devargs_parse(struct rte_devargs *da, const char *dev)
 {
 	struct rte_bus *bus = NULL;
 	const char *devname;
-	const size_t maxlen = sizeof(da->name);
 	size_t i;
 
 	if (da == NULL)
 		return -EINVAL;
+
+	const size_t maxlen = sizeof(da->name);
+
 	memset(da, 0, sizeof(*da));
 
 	/* First parse according global device syntax. */
-- 
2.34.1


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

* Re: [PATCH] devargs: fix derefrence before null test
  2023-10-30 11:45 [PATCH] devargs: fix derefrence before null test Weiguo Li
@ 2023-10-30 16:24 ` Stephen Hemminger
  0 siblings, 0 replies; 2+ messages in thread
From: Stephen Hemminger @ 2023-10-30 16:24 UTC (permalink / raw)
  To: Weiguo Li; +Cc: dev, stable, Weiguo Li

On Mon, 30 Oct 2023 19:45:29 +0800
Weiguo Li <liwg06@foxmail.com> wrote:

> diff --git a/lib/eal/common/eal_common_devargs.c
> b/lib/eal/common/eal_common_devargs.c index fb5d0a293b..8d6c3938eb
> 100644 --- a/lib/eal/common/eal_common_devargs.c
> +++ b/lib/eal/common/eal_common_devargs.c
> @@ -185,11 +185,13 @@ rte_devargs_parse(struct rte_devargs *da, const
> char *dev) {
>  	struct rte_bus *bus = NULL;
>  	const char *devname;
> -	const size_t maxlen = sizeof(da->name);
>  	size_t i;
>  
>  	if (da == NULL)
>  		return -EINVAL;
> +
> +	const size_t maxlen = sizeof(da->name);
> +
>  	memset(da, 0, sizeof(*da));
>  
>  	/* First parse according global device syntax. */

NAK
This patch is not necessary. Doing sizeof() on a NULL structure pointer
is allowed. It is valid C.

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

end of thread, other threads:[~2023-10-30 16:24 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-10-30 11:45 [PATCH] devargs: fix derefrence before null test Weiguo Li
2023-10-30 16:24 ` Stephen Hemminger

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