app/testpmd: fix potential memory leak
authorKirill Rybalchenko <kirill.rybalchenko@intel.com>
Thu, 2 Nov 2017 10:13:41 +0000 (10:13 +0000)
committerFerruh Yigit <ferruh.yigit@intel.com>
Tue, 7 Nov 2017 08:03:02 +0000 (08:03 +0000)
Fix potential memory leak in cmd_ddp_info_parsed() function.

Coverity issue: 195044
Fixes: a8e005696c7b ("app/testpmd: get ddp profile protocol info")

Signed-off-by: Kirill Rybalchenko <kirill.rybalchenko@intel.com>
Reviewed-by: Ferruh Yigit <ferruh.yigit@intel.com>
app/test-pmd/cmdline.c

index e5c42b8..f71d963 100644 (file)
@@ -14362,7 +14362,7 @@ cmd_ddp_info_parsed(
        uint32_t dev_num = 0;
        struct rte_pmd_i40e_ddp_device_id *devs;
        uint32_t proto_num = 0;
-       struct rte_pmd_i40e_proto_info *proto;
+       struct rte_pmd_i40e_proto_info *proto = NULL;
        uint32_t pctype_num = 0;
        struct rte_pmd_i40e_ptype_info *pctype;
        uint32_t ptype_num = 0;
@@ -14541,9 +14541,10 @@ no_print_pctypes:
        free(ptype);
        printf("\n");
 
-       free(proto);
        ret = 0;
 no_print_return:
+       if (proto)
+               free(proto);
 #endif
        if (ret == -ENOTSUP)
                printf("Function not supported in PMD driver\n");