Pointer was being dereferenced without NULL checking.

Coverity issue: 357768

Fixes: 8c8066ea6a7b ("trace: add trace mode configuration parameter")

Signed-off-by: Sunil Kumar Kori <sk...@marvell.com>
---
 lib/librte_eal/common/eal_common_trace_utils.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/lib/librte_eal/common/eal_common_trace_utils.c 
b/lib/librte_eal/common/eal_common_trace_utils.c
index fce8892c3..119e97119 100644
--- a/lib/librte_eal/common/eal_common_trace_utils.c
+++ b/lib/librte_eal/common/eal_common_trace_utils.c
@@ -227,15 +227,16 @@ int
 eal_trace_mode_args_save(const char *optarg)
 {
        struct trace *trace = trace_obj_get();
-       size_t len = strlen(optarg);
        unsigned long tmp;
        char *pattern;
+       size_t len;
 
        if (optarg == NULL) {
                trace_err("no optarg is passed");
                return -EINVAL;
        }
 
+       len = strlen(optarg);
        if (len == 0) {
                trace_err("value is not provided with option");
                return -EINVAL;
-- 
2.17.1

Reply via email to