diff options
author | scottl <scottl@FreeBSD.org> | 2006-02-04 06:08:19 +0000 |
---|---|---|
committer | scottl <scottl@FreeBSD.org> | 2006-02-04 06:08:19 +0000 |
commit | 4fcf1e603c8e1a118fe3e982ba5355923e2c9c44 (patch) | |
tree | dade486fb8eee6a1962618aa56066f81aef366ba /sys/dev/asr | |
parent | 4bb5d9e37d7cead41d3f9699af1c8b23bfc42017 (diff) | |
download | FreeBSD-src-4fcf1e603c8e1a118fe3e982ba5355923e2c9c44.zip FreeBSD-src-4fcf1e603c8e1a118fe3e982ba5355923e2c9c44.tar.gz |
Fix a possible memory leak in asr_attach.
Diffstat (limited to 'sys/dev/asr')
-rw-r--r-- | sys/dev/asr/asr.c | 17 |
1 files changed, 12 insertions, 5 deletions
diff --git a/sys/dev/asr/asr.c b/sys/dev/asr/asr.c index c160d76..12b50b5 100644 --- a/sys/dev/asr/asr.c +++ b/sys/dev/asr/asr.c @@ -2337,12 +2337,19 @@ asr_attach(device_t dev) sc->ha_pciDeviceNum = (pci_get_slot(dev) << 3) | pci_get_function(dev); /* Check if the device is there? */ - if ((ASR_resetIOP(sc) == 0) || - ((status = (PI2O_EXEC_STATUS_GET_REPLY)malloc( - sizeof(I2O_EXEC_STATUS_GET_REPLY), M_TEMP, M_WAITOK)) == NULL) || - (ASR_getStatus(sc, status) == NULL)) { + if (ASR_resetIOP(sc) == 0) { + device_printf(dev, "Cannot reset adapter\n"); + return (EIO); + } + if ((status = (PI2O_EXEC_STATUS_GET_REPLY)malloc( + sizeof(I2O_EXEC_STATUS_GET_REPLY), M_TEMP, M_NOWAIT)) == NULL) { + device_printf(dev, "Cannot allocate memory\n"); + return (ENOMEM); + } + if (ASR_getStatus(sc, status) == NULL) { device_printf(dev, "could not initialize hardware\n"); - return(ENODEV); /* Get next, maybe better luck */ + free(status, M_TEMP); + return(ENODEV); } sc->ha_SystemTable.OrganizationID = status->OrganizationID; sc->ha_SystemTable.IOP_ID = status->IOP_ID; |