diff mbox

scsi: qla2xxx: use dma_mapping_error to check map errors

Message ID 1502200531-15219-1-git-send-email-bianpan2016@163.com (mailing list archive)
State Accepted, archived
Headers show

Commit Message

Pan Bian Aug. 8, 2017, 1:55 p.m. UTC
The return value of dma_map_single() should be checked by
dma_mapping_error(). However, in function qla26xx_dport_diagnostics(), its
return value is checked against NULL, which could result in failures.

Signed-off-by: Pan Bian <bianpan2016@163.com>
---
 drivers/scsi/qla2xxx/qla_mbx.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Madhani, Himanshu Aug. 8, 2017, 3:24 p.m. UTC | #1
> On Aug 8, 2017, at 6:55 AM, Pan Bian <bianpan2016@163.com> wrote:
> 
> The return value of dma_map_single() should be checked by
> dma_mapping_error(). However, in function qla26xx_dport_diagnostics(), its
> return value is checked against NULL, which could result in failures.
> 
> Signed-off-by: Pan Bian <bianpan2016@163.com>
> ---
> drivers/scsi/qla2xxx/qla_mbx.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/scsi/qla2xxx/qla_mbx.c b/drivers/scsi/qla2xxx/qla_mbx.c
> index 7c6d1a4..eafb709 100644
> --- a/drivers/scsi/qla2xxx/qla_mbx.c
> +++ b/drivers/scsi/qla2xxx/qla_mbx.c
> @@ -5817,7 +5817,7 @@ struct cs84xx_mgmt_cmd {
> 
> 	dd_dma = dma_map_single(&vha->hw->pdev->dev,
> 	    dd_buf, size, DMA_FROM_DEVICE);
> -	if (!dd_dma) {
> +	if (dma_mapping_error(&vha->hw->pdev->dev, dd_dma)) {
> 		ql_log(ql_log_warn, vha, 0x1194, "Failed to map dma buffer.\n");
> 		return QLA_MEMORY_ALLOC_FAILED;
> 	}
> -- 
> 1.9.1
> 
> 

Looks Good. Thanks for the patch 

Acked-by: Himanshu Madhani <himanshu.madhani@cavium.com>

Thanks,
- Himanshu
Martin K. Petersen Aug. 11, 2017, 12:06 a.m. UTC | #2
Pan,

> The return value of dma_map_single() should be checked by
> dma_mapping_error(). However, in function qla26xx_dport_diagnostics(),
> its return value is checked against NULL, which could result in
> failures.

Applied to 4.14/scsi-queue.
diff mbox

Patch

diff --git a/drivers/scsi/qla2xxx/qla_mbx.c b/drivers/scsi/qla2xxx/qla_mbx.c
index 7c6d1a4..eafb709 100644
--- a/drivers/scsi/qla2xxx/qla_mbx.c
+++ b/drivers/scsi/qla2xxx/qla_mbx.c
@@ -5817,7 +5817,7 @@  struct cs84xx_mgmt_cmd {
 
 	dd_dma = dma_map_single(&vha->hw->pdev->dev,
 	    dd_buf, size, DMA_FROM_DEVICE);
-	if (!dd_dma) {
+	if (dma_mapping_error(&vha->hw->pdev->dev, dd_dma)) {
 		ql_log(ql_log_warn, vha, 0x1194, "Failed to map dma buffer.\n");
 		return QLA_MEMORY_ALLOC_FAILED;
 	}