[PATCH] devargs: fix derefrence before null test
Stephen Hemminger
stephen at networkplumber.org
Mon Oct 30 17:24:06 CET 2023
On Mon, 30 Oct 2023 19:45:29 +0800
Weiguo Li <liwg06 at 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.
More information about the stable
mailing list