lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [day] [month] [year] [list]
Message-ID: <aIF2RrQZpJora09i@pc>
Date: Thu, 24 Jul 2025 00:54:46 +0100
From: Salah Triki <salah.triki@...il.com>
To: Adaptec OEM Raid Solutions <aacraid@...rosemi.com>,
	"James E.J. Bottomley" <James.Bottomley@...senpartnership.com>,
	"Martin K. Petersen" <martin.petersen@...cle.com>,
	linux-scsi@...r.kernel.org, linux-kernel@...r.kernel.org
Cc: salah.triki@...il.com
Subject: [PATCH] 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 <salah.triki@...il.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


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ