scsi: ips: Quit ips_flush_and_reset() if dma allocation fails
Subsystems (3)
PATCH 1/1 scsi: ips: Quit ips_flush_and_reset() if dma allocation fails
dma_free_coherent() and (*ha->func.reset) need to be called only when dma_alloc_coherent() succeed. So, if it fails, exit ips_flush_and_reset().
Signed-off-by Salah Triki <[email protected]>
Tested-by Compile only
--- drivers/scsi/ips.c | 43 ++++++++++++++++++++++--------------------- 1 file changed, 22 insertions(+), 21 deletions(-)
drivers/scsi/ips.c +22 -21
@@ -4545,26 +4545,28 @@ ips_flush_and_reset(ips_ha_t *ha)/* Create a usuable SCB */ scb =dma_alloc_coherent (&ha->pcidev->dev,sizeof (ips_scb_t), &command_dma,GFP_KERNEL ); -if (scb) { -memset (scb,0 ,sizeof (ips_scb_t)); -ips_init_scb (ha, scb); - scb->scb_busaddr = command_dma; - - scb->timeout = ips_cmd_timeout; - scb->cdb[0 ] =IPS_CMD_FLUSH ; - - scb->cmd.flush_cache.op_code =IPS_CMD_FLUSH ; - scb->cmd.flush_cache.command_id =IPS_MAX_CMDS ;/* Use an ID that would otherwise not exist */ - scb->cmd.flush_cache.state =IPS_NORM_STATE ; - scb->cmd.flush_cache.reserved =0 ; - scb->cmd.flush_cache.reserved2 =0 ; - scb->cmd.flush_cache.reserved3 =0 ; - scb->cmd.flush_cache.reserved4 =0 ; - - ret =ips_send_cmd (ha, scb);/* Send the Flush Command */ - -if (ret ==IPS_SUCCESS ) { - time =60 *IPS_ONE_SEC ;/* Max Wait time is 60 seconds */ +if (!scb) +return ; + +memset (scb,0 ,sizeof (ips_scb_t)); +ips_init_scb (ha, scb); + scb->scb_busaddr = command_dma; + + scb->timeout = ips_cmd_timeout; + scb->cdb[0 ] =IPS_CMD_FLUSH ; + + scb->cmd.flush_cache.op_code =IPS_CMD_FLUSH ; + scb->cmd.flush_cache.command_id =IPS_MAX_CMDS ;/* Use an ID that would otherwise not exist */ + scb->cmd.flush_cache.state =IPS_NORM_STATE ; + scb->cmd.flush_cache.reserved =0 ; + scb->cmd.flush_cache.reserved2 =0 ; + scb->cmd.flush_cache.reserved3 =0 ; + scb->cmd.flush_cache.reserved4 =0 ; + + ret =ips_send_cmd (ha, scb);/* Send the Flush Command */ + +if (ret ==IPS_SUCCESS ) { + time =60 *IPS_ONE_SEC ;/* Max Wait time is 60 seconds */ done =0 ;while ((time >0 ) && (!done)) {
@@ -4574,7 +4576,6 @@ ips_flush_and_reset(ips_ha_t *ha) time--; } } - }/* Now RESET and INIT the adapter */ (*ha->func.reset) (ha);
Signature · 1 line
2.43.0