net/mvpp2: fix memory leak in error path
authorYunjian Wang <wangyunjian@huawei.com>
Thu, 22 Oct 2020 04:25:27 +0000 (12:25 +0800)
committerFerruh Yigit <ferruh.yigit@intel.com>
Tue, 3 Nov 2020 22:24:26 +0000 (23:24 +0100)
commit1b2c17d60d978d2570baa9e5c478ebca1fce3859
treebec628c200fa8e35abd1c969a827fc28e9aa548c
parent8bb7b198297d4d33b720b69480e2b41fb9ca91fb
net/mvpp2: fix memory leak in error path

In mrvl_create() allocated memory for 'mtr', we don't free it
when profile get fails and it will lead to memory leak.

We can get profile at the beginning of the function to
fix it, before calling mtr = rte_zmalloc_socket().

Fixes: cdb53f8da628 ("net/mvpp2: support metering")
Cc: stable@dpdk.org
Signed-off-by: Yunjian Wang <wangyunjian@huawei.com>
Acked-by: Liron Himi <lironh@marvell.com>
drivers/net/mvpp2/mrvl_mtr.c