metrics: fix memory leak on allocation failure
authorCiara Power <ciara.power@intel.com>
Thu, 17 Sep 2020 15:03:41 +0000 (16:03 +0100)
committerDavid Marchand <david.marchand@redhat.com>
Tue, 3 Nov 2020 21:45:24 +0000 (22:45 +0100)
commita5c79ad0f0e4e2b61eff2ebb19ae556f4e257c47
tree6b7b8ace5261570df95686d0657a522096a135db
parentfc61d9a89b610d70797ae3f23128091f09ec917f
metrics: fix memory leak on allocation failure

If an error occurred when allocating memory for metrics or names,
the function returned without freeing allocated memory. This is now
fixed to avoid the resource leak in the case that either metrics or
names had been successfully allocated memory.

Coverity issue: 362053
Fixes: c5b7197f662e ("telemetry: move some functions to metrics library")
Cc: stable@dpdk.org
Reported-by: Gaurav Singh <gaurav1086@gmail.com>
Signed-off-by: Ciara Power <ciara.power@intel.com>
Acked-by: John McNamara <john.mcnamara@intel.com>
lib/librte_metrics/rte_metrics_telemetry.c