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: <20230417064631.1939-1-jiasheng@iscas.ac.cn>
Date:   Mon, 17 Apr 2023 14:46:31 +0800
From:   Jiasheng Jiang <jiasheng@...as.ac.cn>
To:     jejb@...ux.ibm.com, martin.petersen@...cle.com, yanaijie@...wei.com
Cc:     linux-scsi@...r.kernel.org, linux-kernel@...r.kernel.org,
        Jiasheng Jiang <jiasheng@...as.ac.cn>
Subject: [PATCH] scsi: aic94xx: Add missing check for dma_map_sg()

Add check for dma_map_sg() and return error if it fails.
Moreover, unmap the first buffer when the second dma_map_sg() fails.

Fixes: 2908d778ab3e ("[SCSI] aic94xx: new driver")
Signed-off-by: Jiasheng Jiang <jiasheng@...as.ac.cn>
---
 drivers/scsi/aic94xx/aic94xx_task.c | 13 +++++++++++--
 1 file changed, 11 insertions(+), 2 deletions(-)

diff --git a/drivers/scsi/aic94xx/aic94xx_task.c b/drivers/scsi/aic94xx/aic94xx_task.c
index 7f0208300110..0ff7aac0bb29 100644
--- a/drivers/scsi/aic94xx/aic94xx_task.c
+++ b/drivers/scsi/aic94xx/aic94xx_task.c
@@ -419,11 +419,20 @@ static int asd_build_smp_ascb(struct asd_ascb *ascb, struct sas_task *task,
 	struct asd_ha_struct *asd_ha = ascb->ha;
 	struct domain_device *dev = task->dev;
 	struct scb *scb;
+	int num;
 
-	dma_map_sg(&asd_ha->pcidev->dev, &task->smp_task.smp_req, 1,
+	num = dma_map_sg(&asd_ha->pcidev->dev, &task->smp_task.smp_req, 1,
 		   DMA_TO_DEVICE);
-	dma_map_sg(&asd_ha->pcidev->dev, &task->smp_task.smp_resp, 1,
+	if (num == 0)
+		return -ENOMEM;
+
+	num = dma_map_sg(&asd_ha->pcidev->dev, &task->smp_task.smp_resp, 1,
 		   DMA_FROM_DEVICE);
+	if (num == 0) {
+		dma_unmap_sg(&asd_ha->pcidev->dev, &task->smp_task.smp_req, 1,
+			     DMA_TO_DEVICE);
+		return -ENOMEM;
+	}
 
 	scb = ascb->scb;
 
-- 
2.25.1

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ