diff mbox series

scsi: libsas: Add missing check for dma_map_single

Message ID 20221228042431.24923-1-jiasheng@iscas.ac.cn (mailing list archive)
State Deferred
Headers show
Series scsi: libsas: Add missing check for dma_map_single | expand

Commit Message

Jiasheng Jiang Dec. 28, 2022, 4:24 a.m. UTC
Add check for dma_map_single and return error if it fails in order
to avoid invalid dma address.

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

Comments

Jason Yan Jan. 28, 2023, 2:41 a.m. UTC | #1
Hi Jiasheng,

This patch looks good to me, but can you change your subject to "scsi: 
aic94xx: Add missing check for dma_map_single" since this is not in 
libsas code.

Thanks,
Jason

On 2022/12/28 12:24, Jiasheng Jiang wrote:
> Add check for dma_map_single and return error if it fails in order
> to avoid invalid dma address.
> 
> Fixes: 2908d778ab3e ("[SCSI] aic94xx: new driver")
> Signed-off-by: Jiasheng Jiang <jiasheng@iscas.ac.cn>
> ---
>   drivers/scsi/aic94xx/aic94xx_task.c | 3 +++
>   1 file changed, 3 insertions(+)
> 
> diff --git a/drivers/scsi/aic94xx/aic94xx_task.c b/drivers/scsi/aic94xx/aic94xx_task.c
> index ed119a3f6f2e..7f0208300110 100644
> --- a/drivers/scsi/aic94xx/aic94xx_task.c
> +++ b/drivers/scsi/aic94xx/aic94xx_task.c
> @@ -50,6 +50,9 @@ static int asd_map_scatterlist(struct sas_task *task,
>   		dma_addr_t dma = dma_map_single(&asd_ha->pcidev->dev, p,
>   						task->total_xfer_len,
>   						task->data_dir);
> +		if (dma_mapping_error(&asd_ha->pcidev->dev, dma))
> +			return -ENOMEM;
> +
>   		sg_arr[0].bus_addr = cpu_to_le64((u64)dma);
>   		sg_arr[0].size = cpu_to_le32(task->total_xfer_len);
>   		sg_arr[0].flags |= ASD_SG_EL_LIST_EOL;
>
diff mbox series

Patch

diff --git a/drivers/scsi/aic94xx/aic94xx_task.c b/drivers/scsi/aic94xx/aic94xx_task.c
index ed119a3f6f2e..7f0208300110 100644
--- a/drivers/scsi/aic94xx/aic94xx_task.c
+++ b/drivers/scsi/aic94xx/aic94xx_task.c
@@ -50,6 +50,9 @@  static int asd_map_scatterlist(struct sas_task *task,
 		dma_addr_t dma = dma_map_single(&asd_ha->pcidev->dev, p,
 						task->total_xfer_len,
 						task->data_dir);
+		if (dma_mapping_error(&asd_ha->pcidev->dev, dma))
+			return -ENOMEM;
+
 		sg_arr[0].bus_addr = cpu_to_le64((u64)dma);
 		sg_arr[0].size = cpu_to_le32(task->total_xfer_len);
 		sg_arr[0].flags |= ASD_SG_EL_LIST_EOL;