devargs: reset driver name pointer on parsing failure
authorEmmanuel Roullit <emmanuel.roullit@gmail.com>
Tue, 24 Jan 2017 20:26:56 +0000 (21:26 +0100)
committerThomas Monjalon <thomas.monjalon@6wind.com>
Sun, 29 Jan 2017 22:34:07 +0000 (23:34 +0100)
The pointer set by strdup() needs to be cleared on failure to avoid a
potential double-free from the caller.

Found with clang static analysis:
lib/librte_eal/common/eal_common_devargs.c:123:2:
warning: Attempt to free released memory
        free(buf);
        ^~~~~~~~~

Fixes: 0fe11ec592b2 ("eal: add vdev init and uninit")

Signed-off-by: Emmanuel Roullit <emmanuel.roullit@gmail.com>
lib/librte_eal/common/eal_common_devargs.c

index e403717..ffa8ad9 100644 (file)
@@ -72,6 +72,7 @@ rte_eal_parse_devargs_str(const char *devargs_str,
 
        if (*drvargs == NULL) {
                free(*drvname);
+               *drvname = NULL;
                return -1;
        }
        return 0;