Print this page
5253 kmem_alloc/kmem_zalloc won't fail with KM_SLEEP
5254 getrbuf won't fail with KM_SLEEP
@@ -183,24 +183,15 @@
ha->instance);
return (0);
}
xp = kmem_zalloc(sizeof (ql_xioctl_t), KM_SLEEP);
- if (xp == NULL) {
- EL(ha, "failed, kmem_zalloc\n");
- return (ENOMEM);
- }
ha->xioctl = xp;
/* Allocate AEN tracking buffer */
xp->aen_tracking_queue = kmem_zalloc(EXT_DEF_MAX_AEN_QUEUE *
sizeof (EXT_ASYNC_EVENT), KM_SLEEP);
- if (xp->aen_tracking_queue == NULL) {
- EL(ha, "failed, kmem_zalloc-2\n");
- ql_free_xioctl_resource(ha);
- return (ENOMEM);
- }
QL_PRINT_9(CE_CONT, "(%d): done\n", ha->instance);
return (0);
}
@@ -1528,16 +1519,10 @@
}
/* Allocate command block. */
pkt_size = (uint32_t)(sizeof (ql_mbx_iocb_t) + pld_byte_cnt);
pkt = kmem_zalloc(pkt_size, KM_SLEEP);
- if (pkt == NULL) {
- EL(ha, "failed, kmem_zalloc\n");
- cmd->Status = EXT_STATUS_NO_MEMORY;
- cmd->ResponseLen = 0;
- return;
- }
pld = (caddr_t)pkt + sizeof (ql_mbx_iocb_t);
/* Get command payload data. */
if (ql_get_buffer_data((caddr_t)(uintptr_t)cmd->RequestAdr, pld,
cmd->RequestLen, mode) != cmd->RequestLen) {
@@ -2138,16 +2123,10 @@
scsi_req.direction == EXT_DEF_SCSI_PASSTHRU_DATA_OUT) &&
cmd->ResponseLen) {
pld_size = cmd->ResponseLen;
pkt_size = (uint32_t)(sizeof (ql_mbx_iocb_t) + pld_size);
pkt = kmem_zalloc(pkt_size, KM_SLEEP);
- if (pkt == NULL) {
- EL(ha, "failed, kmem_zalloc\n");
- cmd->Status = EXT_STATUS_NO_MEMORY;
- cmd->ResponseLen = 0;
- return;
- }
pld = (caddr_t)pkt + sizeof (ql_mbx_iocb_t);
/* Get DMA memory for the IOCB */
if (ql_get_dma_mem(ha, dma_mem, pld_size, LITTLE_ENDIAN_DMA,
QL_DMA_DATA_ALIGN) != QL_SUCCESS) {
@@ -2196,15 +2175,10 @@
(CFG_IST(ha, CFG_CTRL_24258081) ? 0 : CF_STAG);
cmd->ResponseLen = 0;
pkt_size = sizeof (ql_mbx_iocb_t);
pkt = kmem_zalloc(pkt_size, KM_SLEEP);
- if (pkt == NULL) {
- EL(ha, "failed, kmem_zalloc-2\n");
- cmd->Status = EXT_STATUS_NO_MEMORY;
- return;
- }
pld = NULL;
pld_size = 0;
}
/* retries = ha->port_down_retry_count; */
@@ -3360,16 +3334,10 @@
return;
}
/* Allocate command memory. */
bp = kmem_zalloc(plbreq.TransferCount, KM_SLEEP);
- if (bp == NULL) {
- EL(ha, "failed, kmem_zalloc\n");
- cmd->Status = EXT_STATUS_NO_MEMORY;
- cmd->ResponseLen = 0;
- return;
- }
/* Get loopback data. */
if (ql_get_buffer_data((caddr_t)(uintptr_t)plbreq.BufferAddress,
bp, plbreq.TransferCount, mode) != plbreq.TransferCount) {
EL(ha, "failed, ddi_copyin-2\n");
@@ -3658,16 +3626,10 @@
}
}
/* Allocate memory for command. */
tmp_buf = kmem_zalloc(SEND_RNID_RSP_SIZE, KM_SLEEP);
- if (tmp_buf == NULL) {
- EL(ha, "failed, kmem_zalloc\n");
- cmd->Status = EXT_STATUS_NO_MEMORY;
- cmd->ResponseLen = 0;
- return;
- }
if (local_hba) {
rval = ql_get_rnid_params(ha, SEND_RNID_RSP_SIZE, tmp_buf);
if (rval != QL_SUCCESS) {
EL(ha, "failed, get_rnid_params_mbx=%xh\n", rval);
@@ -4029,14 +3991,10 @@
return (0);
}
pkt_size = sizeof (ql_mbx_iocb_t) + sizeof (ql_rpt_lun_lst_t);
pkt = kmem_zalloc(pkt_size, KM_SLEEP);
- if (pkt == NULL) {
- EL(ha, "failed, kmem_zalloc\n");
- return (0);
- }
rpt = (ql_rpt_lun_lst_t *)((caddr_t)pkt + sizeof (ql_mbx_iocb_t));
/* Get DMA memory for the IOCB */
if (ql_get_dma_mem(ha, &dma_mem, sizeof (ql_rpt_lun_lst_t),
LITTLE_ENDIAN_DMA, QL_DMA_RING_ALIGN) != QL_SUCCESS) {
@@ -4273,14 +4231,10 @@
QL_PRINT_9(CE_CONT, "(%d): started\n", ha->instance);
pkt_size = sizeof (ql_mbx_iocb_t) + INQ_DATA_SIZE;
pkt = kmem_zalloc(pkt_size, KM_SLEEP);
- if (pkt == NULL) {
- EL(ha, "failed, kmem_zalloc\n");
- return (0);
- }
inq = (uint8_t *)((caddr_t)pkt + sizeof (ql_mbx_iocb_t));
cnt = 0;
for (lun = 0; lun < MAX_LUNS; lun++) {
@@ -4696,14 +4650,11 @@
if (ha->flash_desc_addr == 0) {
QL_PRINT_9(CE_CONT, "(%d): desc ptr=0\n", ha->instance);
return (QL_FUNCTION_FAILED);
}
- if ((fdesc = kmem_zalloc(sizeof (flash_desc_t), KM_SLEEP)) == NULL) {
- EL(ha, "kmem_zalloc=null\n");
- return (QL_MEMORY_ALLOC_FAILED);
- }
+ fdesc = kmem_zalloc(sizeof (flash_desc_t), KM_SLEEP);
rval = ql_dump_fcode(ha, (uint8_t *)fdesc, sizeof (flash_desc_t),
ha->flash_desc_addr << 2);
if (rval != QL_SUCCESS) {
EL(ha, "read status=%xh\n", rval);
kmem_free(fdesc, sizeof (flash_desc_t));
@@ -5433,16 +5384,10 @@
return;
}
/* Allocate memory for command. */
tmp_buf = kmem_zalloc(sizeof (EXT_RNID_DATA), KM_SLEEP);
- if (tmp_buf == NULL) {
- EL(ha, "failed, kmem_zalloc\n");
- cmd->Status = EXT_STATUS_NO_MEMORY;
- cmd->ResponseLen = 0;
- return;
- }
rval = ql_get_rnid_params(ha, sizeof (EXT_RNID_DATA),
(caddr_t)tmp_buf);
if (rval != QL_SUCCESS) {
/* error */
@@ -5496,16 +5441,10 @@
return;
}
/* Allocate memory for command. */
tmp_buf = kmem_zalloc(sizeof (EXT_RNID_DATA), KM_SLEEP);
- if (tmp_buf == NULL) {
- EL(ha, "failed, kmem_zalloc\n");
- cmd->Status = EXT_STATUS_NO_MEMORY;
- cmd->ResponseLen = 0;
- return;
- }
/* Send command */
rval = ql_get_rnid_params(ha, sizeof (EXT_RNID_DATA),
(caddr_t)tmp_buf);
if (rval != QL_SUCCESS) {
@@ -5633,16 +5572,10 @@
}
}
/* Allocate memory for command. */
ls = kmem_zalloc(sizeof (ql_link_stats_t), KM_SLEEP);
- if (ls == NULL) {
- EL(ha, "failed, kmem_zalloc\n");
- cmd->Status = EXT_STATUS_NO_MEMORY;
- cmd->ResponseLen = 0;
- return;
- }
/*
* I think these are supposed to be port statistics
* the loop ID or port ID should be in cmd->Instance.
*/
@@ -5755,16 +5688,10 @@
}
}
/* Allocate memory for command. */
ls = kmem_zalloc(sizeof (ql_link_stats_t), KM_SLEEP);
- if (ls == NULL) {
- EL(ha, "failed, kmem_zalloc\n");
- cmd->Status = EXT_STATUS_NO_MEMORY;
- cmd->ResponseLen = 0;
- return;
- }
rval = ql_get_link_status(ha, tq->loop_id, sizeof (ql_link_stats_t),
(caddr_t)ls, 0);
if (rval != QL_SUCCESS) {
EL(ha, "failed, get_link_status=%xh, d_id=%xh\n", rval,
@@ -6970,14 +6897,11 @@
QL_PRINT_9(CE_CONT, "(%d): started\n", ha->instance);
/* Process flash layout table header */
len = sizeof (ql_flt_ptr_t);
- if ((bp = kmem_zalloc(len, KM_SLEEP)) == NULL) {
- EL(ha, "kmem_zalloc=null\n");
- return;
- }
+ bp = kmem_zalloc(len, KM_SLEEP);
/* Process pointer to flash layout table */
if ((rval = ql_dump_fcode(ha, bp, len, flt_paddr)) != QL_SUCCESS) {
EL(ha, "fptr dump_flash pos=%xh, status=%xh\n", flt_paddr,
rval);
@@ -7030,14 +6954,11 @@
uint16_t chksum, w16;
QL_PRINT_9(CE_CONT, "(%d): started faddr=%xh\n", ha->instance, faddr);
/* Process flash layout table header */
- if ((bp = kmem_zalloc(FLASH_LAYOUT_TABLE_SIZE, KM_SLEEP)) == NULL) {
- EL(ha, "kmem_zalloc=null\n");
- return;
- }
+ bp = kmem_zalloc(FLASH_LAYOUT_TABLE_SIZE, KM_SLEEP);
fhdr = (ql_flt_hdr_t *)bp;
/* Process flash layout table. */
if ((rval = ql_dump_fcode(ha, bp, FLASH_LAYOUT_TABLE_SIZE, faddr)) !=
QL_SUCCESS) {
@@ -7709,16 +7630,10 @@
return;
}
/* Allocate payload buffer */
payload = kmem_zalloc(FWEXTSIZE, KM_SLEEP);
- if (payload == NULL) {
- EL(ha, "failed, kmem_zalloc\n");
- cmd->Status = EXT_STATUS_NO_MEMORY;
- cmd->ResponseLen = 0;
- return;
- }
/* Sync DMA buffer. */
(void) ddi_dma_sync(ha->fwexttracebuf.dma_handle, 0,
FWEXTSIZE, DDI_DMA_SYNC_FORKERNEL);
@@ -7798,16 +7713,10 @@
return;
}
/* Allocate payload buffer */
payload = kmem_zalloc(FWEXTSIZE, KM_SLEEP);
- if (payload == NULL) {
- EL(ha, "failed, kmem_zalloc\n");
- cmd->Status = EXT_STATUS_NO_MEMORY;
- cmd->ResponseLen = 0;
- return;
- }
/* Sync DMA buffer. */
(void) ddi_dma_sync(ha->fwfcetracebuf.dma_handle, 0,
FWFCESIZE, DDI_DMA_SYNC_FORKERNEL);
@@ -7920,14 +7829,10 @@
uint32_t *ptr32, *org_ptr32;
QL_PRINT_9(CE_CONT, "(%d): started\n", ha->instance);
ptr32 = kmem_zalloc(pci_size, KM_SLEEP);
- if (ptr32 == NULL) {
- EL(ha, "failed kmem_zalloc\n");
- return (ENOMEM);
- }
/* store the initial value of ptr32 */
org_ptr32 = ptr32;
for (pci_os = 0; pci_os < pci_size; pci_os += 4) {
*ptr32 = (uint32_t)ql_pci_config_get32(ha, pci_os);
@@ -8071,16 +7976,10 @@
return;
}
/* Allocate packet. */
pkt = kmem_zalloc(sizeof (ql_mbx_iocb_t), KM_SLEEP);
- if (pkt == NULL) {
- EL(ha, "failed, kmem_zalloc\n");
- cmd->Status = EXT_STATUS_NO_MEMORY;
- cmd->ResponseLen = 0;
- return;
- }
pkt->mvfy.entry_type = VERIFY_MENLO_TYPE;
pkt->mvfy.entry_count = 1;
pkt->mvfy.options_status = LE_16(VMF_DO_NOT_UPDATE_FW);
@@ -8186,18 +8085,10 @@
cmd->Status = EXT_STATUS_NO_MEMORY;
cmd->ResponseLen = 0;
return;
}
pkt = kmem_zalloc(sizeof (ql_mbx_iocb_t), KM_SLEEP);
- if (pkt == NULL) {
- EL(ha, "failed, kmem_zalloc\n");
- kmem_free(dma_mem, sizeof (dma_mem_t));
- ql_restart_hba(ha);
- cmd->Status = EXT_STATUS_NO_MEMORY;
- cmd->ResponseLen = 0;
- return;
- }
/* Get DMA memory for the IOCB */
if (ql_get_dma_mem(ha, dma_mem, fw.TotalByteCount, LITTLE_ENDIAN_DMA,
QL_DMA_DATA_ALIGN) != QL_SUCCESS) {
cmn_err(CE_WARN, "%s(%d): request queue DMA memory "
@@ -8325,17 +8216,10 @@
return;
}
/* Allocate packet. */
pkt = kmem_zalloc(sizeof (ql_mbx_iocb_t), KM_SLEEP);
- if (pkt == NULL) {
- EL(ha, "failed, kmem_zalloc\n");
- ql_restart_driver(ha);
- cmd->Status = EXT_STATUS_NO_MEMORY;
- cmd->ResponseLen = 0;
- return;
- }
pkt->mdata.entry_type = MENLO_DATA_TYPE;
pkt->mdata.entry_count = 1;
pkt->mdata.options_status = (uint16_t)LE_16(info.Operation);
@@ -8821,16 +8705,10 @@
return;
}
/* Allocate memory for command. */
tmp_buf = kmem_zalloc(EXT_DEF_DCBX_PARAM_BUF_SIZE, KM_SLEEP);
- if (tmp_buf == NULL) {
- EL(ha, "failed, kmem_zalloc\n");
- cmd->Status = EXT_STATUS_NO_MEMORY;
- cmd->ResponseLen = 0;
- return;
- }
/* Send command */
rval = ql_get_dcbx_params(ha, EXT_DEF_DCBX_PARAM_BUF_SIZE,
(caddr_t)tmp_buf);
if (rval != QL_SUCCESS) {
/* error */
@@ -9069,16 +8947,10 @@
return;
}
/* Allocate memory for command. */
tmp_buf = kmem_zalloc(size, KM_SLEEP);
- if (tmp_buf == NULL) {
- EL(ha, "failed, kmem_zalloc\n");
- cmd->Status = EXT_STATUS_NO_MEMORY;
- cmd->ResponseLen = 0;
- return;
- }
if (!(info.Operation & MENLO_OP_GET_INFO)) {
EL(ha, "Invalid request for 81XX\n");
kmem_free(tmp_buf, size);
cmd->Status = EXT_STATUS_ERR;
@@ -9152,16 +9024,10 @@
cmd->ResponseLen = 0;
return;
}
/* Allocate memory for command. */
tmp_buf = kmem_zalloc(fcf_list.BufSize, KM_SLEEP);
- if (tmp_buf == NULL) {
- EL(ha, "failed, kmem_zalloc\n");
- cmd->Status = EXT_STATUS_NO_MEMORY;
- cmd->ResponseLen = 0;
- return;
- }
/* build the descriptor */
if (fcf_list.Options) {
mb_fcf_list.options = FCF_LIST_RETURN_ONE;
} else {
mb_fcf_list.options = FCF_LIST_RETURN_ALL;