diff options
author | Kevin O'Connor <kevin@koconnor.net> | 2015-06-30 11:10:41 -0400 |
---|---|---|
committer | Kevin O'Connor <kevin@koconnor.net> | 2015-07-04 14:23:01 -0400 |
commit | 3abdc7c018c727b96549930d2929623ca381fff7 (patch) | |
tree | 27ff8afdb34f608875fc0fa5edf9a81ab94a4354 /src/hw/ahci.c | |
parent | 1202f03583f3b8b46e2de6b82630054d53e24801 (diff) | |
download | seabios-3abdc7c018c727b96549930d2929623ca381fff7.tar.gz |
Make sure all code checks for malloc failures
This is the result of an audit of callers of the malloc_XXX() and
memalign_XXX() calls. All callers need to check if these functions
return NULL.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Diffstat (limited to 'src/hw/ahci.c')
-rw-r--r-- | src/hw/ahci.c | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/src/hw/ahci.c b/src/hw/ahci.c index 3193d81a..0d71cc40 100644 --- a/src/hw/ahci.c +++ b/src/hw/ahci.c @@ -405,6 +405,14 @@ static struct ahci_port_s* ahci_port_realloc(struct ahci_port_s *port) port->list = memalign_high(1024, 1024); port->fis = memalign_high(256, 256); port->cmd = memalign_high(256, 256); + if (!port->list || !port->fis || !port->cmd) { + warn_noalloc(); + free(port->list); + free(port->fis); + free(port->cmd); + free(port); + return NULL; + } ahci_port_writel(port->ctrl, port->pnr, PORT_LST_ADDR, (u32)port->list); ahci_port_writel(port->ctrl, port->pnr, PORT_FIS_ADDR, (u32)port->fis); |