All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] scsi: ips: Quit ips_flush_and_reset() if dma allocation fails
@ 2025-07-23 23:54 Salah Triki
  0 siblings, 0 replies; only message in thread
From: Salah Triki @ 2025-07-23 23:54 UTC (permalink / raw)
  To: Adaptec OEM Raid Solutions, James E.J. Bottomley,
	Martin K. Petersen, linux-scsi, linux-kernel
  Cc: salah.triki

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 <salah.triki@gmail.com>
Tested-by: Compile only
---
 drivers/scsi/ips.c | 43 ++++++++++++++++++++++---------------------
 1 file changed, 22 insertions(+), 21 deletions(-)

diff --git a/drivers/scsi/ips.c b/drivers/scsi/ips.c
index 94adb6ac02a4..e51bfb797aa5 100644
--- a/drivers/scsi/ips.c
+++ b/drivers/scsi/ips.c
@@ -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);
-- 
2.43.0


^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2025-07-23 23:54 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-07-23 23:54 [PATCH] scsi: ips: Quit ips_flush_and_reset() if dma allocation fails Salah Triki

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.