Paul Menzel (paulepanter@users.sourceforge.net) just uploaded a new patch set to gerrit, which you can find at http://review.coreboot.org/7980
-gerrit
commit 5a6ee99a66a789eaad6c23c08be1199132669e36 Author: Paul Menzel paulepanter@users.sourceforge.net Date: Mon Dec 29 21:48:55 2014 +0100
libpayload/drivers/storage/ahci.c: Fix resource leak
CID 1260719: Resource leak (RESOURCE_LEAK) Variable "dev" going out of scope leaks the storage it points to.
So free the memory space pointed to by `dev` before returning.
Change-Id: Iabf00c9dc744a24d04adff6d253d0295b130d9c4 Signed-off-by: Paul Menzel paulepanter@users.sourceforge.net Found-by: Coverity Scan --- payloads/libpayload/drivers/storage/ahci.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/payloads/libpayload/drivers/storage/ahci.c b/payloads/libpayload/drivers/storage/ahci.c index 4eef843..a17383a 100644 --- a/payloads/libpayload/drivers/storage/ahci.c +++ b/payloads/libpayload/drivers/storage/ahci.c @@ -120,12 +120,16 @@ static int ahci_dev_init(hba_ctrl_t *const ctrl, memset((void *)rcvd_fis, '\0', sizeof(*rcvd_fis));
/* Set command list base and received FIS base. */ - if (ahci_cmdengine_stop(port)) + if (ahci_cmdengine_stop(port)) { + free(dev); return 1; + } port->cmdlist_base = virt_to_phys(cmdlist); port->frameinfo_base = virt_to_phys(rcvd_fis); - if (ahci_cmdengine_start(port)) + if (ahci_cmdengine_start(port)) { + free(dev); return 1; + } /* Put port into active state. */ port->cmd_stat |= HBA_PxCMD_ICC_ACTIVE;