devargs: fix null dereferencing on failure
authorPawel Wodkowski <pawelx.wodkowski@intel.com>
Mon, 2 Mar 2015 11:09:22 +0000 (12:09 +0100)
committerThomas Monjalon <thomas.monjalon@6wind.com>
Mon, 2 Mar 2015 18:40:54 +0000 (19:40 +0100)
On failure devargs->args should not be accessed if devargs is NULL.

Fixes: c07691ae1089 ("devargs: remove limit on parameters length")

Signed-off-by: Pawel Wodkowski <pawelx.wodkowski@intel.com>
Acked-by: David Marchand <david.marchand@6wind.com>
lib/librte_eal/common/eal_common_devargs.c

index 9b110f7..615945e 100644 (file)
@@ -124,12 +124,13 @@ rte_eal_devargs_add(enum rte_devtype devtype, const char *devargs_str)
        return 0;
 
 fail:
-       if (devargs->args)
-               free(devargs->args);
        if (buf)
                free(buf);
-       if (devargs)
+       if (devargs) {
+               free(devargs->args);
                free(devargs);
+       }
+
        return -1;
 }