Stefan Reinauer (stefan.reinauer@coreboot.org) just uploaded a new patch set to gerrit, which you can find at https://review.coreboot.org/7980
-gerrit
commit 0ee9bbf586205d5ea8bbfad70b0fe225a9c124fd 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 deae9e2..8820301 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;