From 6c2c3eb5a7443269fb2851c7c9a5021e6375722e Mon Sep 17 00:00:00 2001 From: Agalya Babu RadhaKrishnan Date: Tue, 10 Sep 2019 08:30:55 +0100 Subject: [PATCH] bus/fslmc: fix resource leak 1 issue caught by coverity (issue 344967). Leaked_storage: Variable sep going out of scope leaks the storage it points to. When 'sep' is not null and sep_exist is 0, 'sep' is freed before going out of scope of the function irrespective of 'addr' exists or not. Coverity issue: 344967 Fixes: e67a61614d0b ("bus/fslmc: support device iteration") Cc: stable@dpdk.org Signed-off-by: Agalya Babu RadhaKrishnan Acked-by: Sachin Saxena --- drivers/bus/fslmc/fslmc_bus.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/drivers/bus/fslmc/fslmc_bus.c b/drivers/bus/fslmc/fslmc_bus.c index 4116552c6d..9caf5b6b96 100644 --- a/drivers/bus/fslmc/fslmc_bus.c +++ b/drivers/bus/fslmc/fslmc_bus.c @@ -292,10 +292,13 @@ jump_out: goto err_out; } - if (addr) + if (addr) { strcpy(addr, sep); + if (!sep_exists && sep) + free(sep); + return 0; + } - return 0; err_out: if (!sep_exists && sep) free(sep); -- 2.20.1