From 9d6623f13fe58edb5c773c8915ec610b37bb8774 Mon Sep 17 00:00:00 2001 From: Luo Ji Date: Thu, 14 Mar 2019 17:02:25 +0800 Subject: [PATCH] MA-14379 [coverity] Resource leak (RESOURCE_LEAK) Fix coverity issue: CID 2970630: Resource leak (RESOURCE_LEAK) leaked_storage: Variable cdns going out of scope leaks the storage it points to. Memory allocated by devm_kzalloc() won't be freed automatically in u-boot, free the memory manually here. Test: Coverity scan pass. Change-Id: I3000a2385941cef3b8b7e01611cfdc999971a4ca Signed-off-by: Luo Ji --- drivers/usb/cdns3/core.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/drivers/usb/cdns3/core.c b/drivers/usb/cdns3/core.c index cdea627..8495fec 100644 --- a/drivers/usb/cdns3/core.c +++ b/drivers/usb/cdns3/core.c @@ -333,6 +333,11 @@ err2: cdns3_remove_roles(cdns); err1: cdns3_disable_clks(cdns->index); + + /* For u-boot, need to free the memory manually here. */ + if (cdns != NULL) + free(cdns); + return ret; } -- 1.9.1