Skip to contentSkip to conversation

eal: reset driver name pointer on failure

PATCH Applied Emmanuel Roullit 2 participants 2 messages Jan 24, 2017 – Jan 29, 2017

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 eal: reset driver name pointer on failure

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 3fe2e5fec82b ("eal: fix argument parsing check")
---
 lib/librte_eal/common/eal_common_devargs.c | 1 +
 1 file changed, 1 insertion(+)
lib/librte_eal/common/eal_common_devargs.c +1 -0
index e403717be..ffa8ad96f 100644
@@ -72,6 +72,7 @@ rte_eal_parse_devargs_str(const char *devargs_str,
 
 	if (*drvargs == NULL) {
 		free(*drvname);
+		*drvname = NULL;
 		return -1;
 	}
 	return 0;
Signature · 1 line
2.11.0
#1 lore raw

2017-01-24 21:26, Emmanuel Roullit:

Quoted 10 lines

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 3fe2e5fec82b ("eal: fix argument parsing check")

The real bug origin is:

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

Applied, thanks