Commit 9d6623f13fe58edb5c773c8915ec610b37bb8774

Authored by Luo Ji
Committed by Ji Luo
1 parent dfdf60c69c

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 <ji.luo@nxp.com>

Showing 1 changed file with 5 additions and 0 deletions Side-by-side Diff

drivers/usb/cdns3/core.c
... ... @@ -333,6 +333,11 @@
333 333 cdns3_remove_roles(cdns);
334 334 err1:
335 335 cdns3_disable_clks(cdns->index);
  336 +
  337 + /* For u-boot, need to free the memory manually here. */
  338 + if (cdns != NULL)
  339 + free(cdns);
  340 +
336 341 return ret;
337 342 }
338 343