Blame SOURCES/0108-scsi-scsi-qla2xxx-Fix-DMA-unmap-leak.patch

3c6e85
From e977659d2f2a9f740bfb740afe48c3e6765ef0fe Mon Sep 17 00:00:00 2001
3c6e85
From: Himanshu Madhani <hmadhani@redhat.com>
3c6e85
Date: Thu, 1 Aug 2019 15:56:08 -0400
3c6e85
Subject: [PATCH 108/124] [scsi] scsi: qla2xxx: Fix DMA unmap leak
3c6e85
3c6e85
Message-id: <20190801155618.12650-109-hmadhani@redhat.com>
3c6e85
Patchwork-id: 267882
3c6e85
O-Subject: [RHEL 7.8 e-stor PATCH 108/118] scsi: qla2xxx: Fix DMA unmap leak
3c6e85
Bugzilla: 1729270
3c6e85
RH-Acked-by: Jarod Wilson <jarod@redhat.com>
3c6e85
RH-Acked-by: Tony Camuso <tcamuso@redhat.com>
3c6e85
3c6e85
From: Himanshu Madhani <hmadhani@marvell.com>
3c6e85
3c6e85
Bugzilla 1729270
3c6e85
3c6e85
With debug kernel we see following wanings indicating memory leak.
3c6e85
3c6e85
[28809.523959] WARNING: CPU: 3 PID: 6790 at lib/dma-debug.c:978
3c6e85
dma_debug_device_change+0x166/0x1d0
3c6e85
[28809.523964] pci 0000:0c:00.6: DMA-API: device driver has pending DMA
3c6e85
allocations while released from device [count=5]
3c6e85
[28809.523964] One of leaked entries details: [device
3c6e85
address=0x00000002aefe4000] [size=8208 bytes] [mapped with DMA_BIDIRECTIONAL]
3c6e85
[mapped as coherent]
3c6e85
3c6e85
Fix this by unmapping DMA memory.
3c6e85
3c6e85
Signed-off-by: Quinn Tran <qutran@marvell.com>
3c6e85
Signed-off-by: Himanshu Madhani <hmadhani@marvell.com>
3c6e85
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
3c6e85
(cherry picked from commit 5d328de64d89400dcf9911125844d8adc0db697f)
3c6e85
Signed-off-by: Himanshu Madhani <hmadhani@redhat.com>
3c6e85
Signed-off-by: Jan Stancek <jstancek@redhat.com>
3c6e85
---
3c6e85
 drivers/scsi/qla2xxx/qla_bsg.c | 4 ++++
3c6e85
 1 file changed, 4 insertions(+)
3c6e85
3c6e85
diff --git a/drivers/scsi/qla2xxx/qla_bsg.c b/drivers/scsi/qla2xxx/qla_bsg.c
3c6e85
index 783541fec019..c59a56aa626b 100644
3c6e85
--- a/drivers/scsi/qla2xxx/qla_bsg.c
3c6e85
+++ b/drivers/scsi/qla2xxx/qla_bsg.c
3c6e85
@@ -333,6 +333,8 @@ qla2x00_process_els(struct fc_bsg_job *bsg_job)
3c6e85
 		dma_map_sg(&ha->pdev->dev, bsg_job->request_payload.sg_list,
3c6e85
 		bsg_job->request_payload.sg_cnt, DMA_TO_DEVICE);
3c6e85
 	if (!req_sg_cnt) {
3c6e85
+		dma_unmap_sg(&ha->pdev->dev, bsg_job->request_payload.sg_list,
3c6e85
+		    bsg_job->request_payload.sg_cnt, DMA_TO_DEVICE);
3c6e85
 		rval = -ENOMEM;
3c6e85
 		goto done_free_fcport;
3c6e85
 	}
3c6e85
@@ -340,6 +342,8 @@ qla2x00_process_els(struct fc_bsg_job *bsg_job)
3c6e85
 	rsp_sg_cnt = dma_map_sg(&ha->pdev->dev, bsg_job->reply_payload.sg_list,
3c6e85
 		bsg_job->reply_payload.sg_cnt, DMA_FROM_DEVICE);
3c6e85
         if (!rsp_sg_cnt) {
3c6e85
+		dma_unmap_sg(&ha->pdev->dev, bsg_job->reply_payload.sg_list,
3c6e85
+		    bsg_job->reply_payload.sg_cnt, DMA_FROM_DEVICE);
3c6e85
 		rval = -ENOMEM;
3c6e85
 		goto done_free_fcport;
3c6e85
 	}
3c6e85
-- 
3c6e85
2.13.6
3c6e85