public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/2] Added pci_mapping_error() call and related clean up
@ 2015-01-18  6:41 Tina Johnson
  2015-01-18  6:41 ` [PATCH 1/2] drivers: scsi: mpt2sas: Added pci_dma_mapping_error() call Tina Johnson
  2015-01-18  6:41 ` [PATCH 2/2] drivers: scsi: mpt2sas: Clean up error handling for calls to pci_map_single Tina Johnson
  0 siblings, 2 replies; 3+ messages in thread
From: Tina Johnson @ 2015-01-18  6:41 UTC (permalink / raw)
  To: JBottomley
  Cc: praveen.krishnamoorthy, sreekanth.reddy, julia.lawall,
	abhijit.mahajan, nagalakshmi.nandigama, MPT-FusionLinux.pdl,
	linux-scsi, linux-kernel, Tina Johnson

Replaced null test on dma handle with pci_dma_mapping_error() and cleaned 
up the error handling code.

Tina Johnson (2):
  drivers: scsi: mpt2sas: Added pci_dma_mapping_error() call
  drivers: scsi: mpt2sas: Clean up error handling for calls to pci_map_single

 drivers/scsi/mpt2sas/mpt2sas_transport.c |   35 +++++++++++++++---------------
 1 file changed, 17 insertions(+), 18 deletions(-)

-- 
1.7.10.4


^ permalink raw reply	[flat|nested] 3+ messages in thread

* [PATCH 1/2] drivers: scsi: mpt2sas: Added pci_dma_mapping_error() call
  2015-01-18  6:41 [PATCH 0/2] Added pci_mapping_error() call and related clean up Tina Johnson
@ 2015-01-18  6:41 ` Tina Johnson
  2015-01-18  6:41 ` [PATCH 2/2] drivers: scsi: mpt2sas: Clean up error handling for calls to pci_map_single Tina Johnson
  1 sibling, 0 replies; 3+ messages in thread
From: Tina Johnson @ 2015-01-18  6:41 UTC (permalink / raw)
  To: JBottomley
  Cc: praveen.krishnamoorthy, sreekanth.reddy, julia.lawall,
	abhijit.mahajan, nagalakshmi.nandigama, MPT-FusionLinux.pdl,
	linux-scsi, linux-kernel, Tina Johnson

Replaced null test on dma handle with  pci_dma_mapping_error()
o check for mapping errors. Coccinelle was used to find cases
that do not check for dma mapping errors:

@rule1@
statement S;
identifier x;
@@

*x = pci_map_single(...);
  if (!x) S

Signed-off-by: Tina Johnson <tinajohnson.1234@gmail.com>
Acked-by: Julia Lawall <julia.lawall@lip6.fr>
---
 drivers/scsi/mpt2sas/mpt2sas_transport.c |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/scsi/mpt2sas/mpt2sas_transport.c b/drivers/scsi/mpt2sas/mpt2sas_transport.c
index e689bf2..b283140 100644
--- a/drivers/scsi/mpt2sas/mpt2sas_transport.c
+++ b/drivers/scsi/mpt2sas/mpt2sas_transport.c
@@ -1962,7 +1962,7 @@ _transport_smp_handler(struct Scsi_Host *shost, struct sas_rphy *rphy,
 	} else {
 		dma_addr_out = pci_map_single(ioc->pdev, bio_data(req->bio),
 		    blk_rq_bytes(req), PCI_DMA_BIDIRECTIONAL);
-		if (!dma_addr_out) {
+		if (pci_dma_mapping_error(ioc->pdev, dma_addr_out)) {
 			printk(MPT2SAS_INFO_FMT "%s(): DMA Addr out = NULL\n",
 			    ioc->name, __func__);
 			rc = -ENOMEM;
@@ -1984,7 +1984,7 @@ _transport_smp_handler(struct Scsi_Host *shost, struct sas_rphy *rphy,
 	} else {
 		dma_addr_in =  pci_map_single(ioc->pdev, bio_data(rsp->bio),
 		    blk_rq_bytes(rsp), PCI_DMA_BIDIRECTIONAL);
-		if (!dma_addr_in) {
+		if (pci_dma_mapping_error(ioc->pdev, dma_addr_in)) {
 			printk(MPT2SAS_INFO_FMT "%s(): DMA Addr in = NULL\n",
 			    ioc->name, __func__);
 			rc = -ENOMEM;
-- 
1.7.10.4


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* [PATCH 2/2] drivers: scsi: mpt2sas: Clean up error handling for calls to pci_map_single
  2015-01-18  6:41 [PATCH 0/2] Added pci_mapping_error() call and related clean up Tina Johnson
  2015-01-18  6:41 ` [PATCH 1/2] drivers: scsi: mpt2sas: Added pci_dma_mapping_error() call Tina Johnson
@ 2015-01-18  6:41 ` Tina Johnson
  1 sibling, 0 replies; 3+ messages in thread
From: Tina Johnson @ 2015-01-18  6:41 UTC (permalink / raw)
  To: JBottomley
  Cc: praveen.krishnamoorthy, sreekanth.reddy, julia.lawall,
	abhijit.mahajan, nagalakshmi.nandigama, MPT-FusionLinux.pdl,
	linux-scsi, linux-kernel, Tina Johnson

*Currently, the error handling code is organized to free dma_addr_out,
 dma_addr_in and then pci_addr_out, pci_addr_in. Since dma_addr_out and
 pci_addr_out are allocated first and then dma_addr_in and  pci_addr_in,
 the error handling code is reorganized to free the in variables first and
 then the out variables. Labels were renamed and gotos altered accordingly.

*At the point of the goto free_pci, neither the in nor the out variables
 are allocated and hence no freeing required. The free_pci label is removed
 and the goto free_pci is replaced with goto out.

Signed-off-by: Tina Johnson <tinajohnson.1234@gmail.com>
Acked-by: Julia Lawall <julia.lawall@lip6.fr>
---
 drivers/scsi/mpt2sas/mpt2sas_transport.c |   31 +++++++++++++++---------------
 1 file changed, 15 insertions(+), 16 deletions(-)

diff --git a/drivers/scsi/mpt2sas/mpt2sas_transport.c b/drivers/scsi/mpt2sas/mpt2sas_transport.c
index b283140..1740506 100644
--- a/drivers/scsi/mpt2sas/mpt2sas_transport.c
+++ b/drivers/scsi/mpt2sas/mpt2sas_transport.c
@@ -1966,7 +1966,7 @@ _transport_smp_handler(struct Scsi_Host *shost, struct sas_rphy *rphy,
 			printk(MPT2SAS_INFO_FMT "%s(): DMA Addr out = NULL\n",
 			    ioc->name, __func__);
 			rc = -ENOMEM;
-			goto free_pci;
+			goto out;
 		}
 	}
 
@@ -1979,7 +1979,7 @@ _transport_smp_handler(struct Scsi_Host *shost, struct sas_rphy *rphy,
 			printk(MPT2SAS_INFO_FMT "%s(): PCI Addr in = NULL\n",
 			    ioc->name, __func__);
 			rc = -ENOMEM;
-			goto unmap;
+			goto release_out;
 		}
 	} else {
 		dma_addr_in =  pci_map_single(ioc->pdev, bio_data(rsp->bio),
@@ -1988,7 +1988,7 @@ _transport_smp_handler(struct Scsi_Host *shost, struct sas_rphy *rphy,
 			printk(MPT2SAS_INFO_FMT "%s(): DMA Addr in = NULL\n",
 			    ioc->name, __func__);
 			rc = -ENOMEM;
-			goto unmap;
+			goto release_out;
 		}
 	}
 
@@ -2000,7 +2000,7 @@ _transport_smp_handler(struct Scsi_Host *shost, struct sas_rphy *rphy,
 			    "%s: failed due to ioc not operational\n",
 			    ioc->name, __func__);
 			rc = -EFAULT;
-			goto unmap;
+			goto release_in;
 		}
 		ssleep(1);
 		ioc_state = mpt2sas_base_get_iocstate(ioc, 1);
@@ -2017,7 +2017,7 @@ _transport_smp_handler(struct Scsi_Host *shost, struct sas_rphy *rphy,
 		printk(MPT2SAS_ERR_FMT "%s: failed obtaining a smid\n",
 		    ioc->name, __func__);
 		rc = -EAGAIN;
-		goto unmap;
+		goto release_in;
 	}
 
 	rc = 0;
@@ -2132,22 +2132,21 @@ _transport_smp_handler(struct Scsi_Host *shost, struct sas_rphy *rphy,
 		rc = -ETIMEDOUT;
 	}
 
- unmap:
-	if (dma_addr_out)
-		pci_unmap_single(ioc->pdev, dma_addr_out, blk_rq_bytes(req),
-		    PCI_DMA_BIDIRECTIONAL);
+ release_in:
 	if (dma_addr_in)
 		pci_unmap_single(ioc->pdev, dma_addr_in, blk_rq_bytes(rsp),
-		    PCI_DMA_BIDIRECTIONAL);
+				 PCI_DMA_BIDIRECTIONAL);
+	if (pci_addr_in)
+		pci_free_consistent(ioc->pdev, blk_rq_bytes(rsp), pci_addr_in,
+				    pci_dma_in);
 
- free_pci:
+ release_out:
+	if (dma_addr_out)
+		pci_unmap_single(ioc->pdev, dma_addr_out, blk_rq_bytes(req),
+				 PCI_DMA_BIDIRECTIONAL);
 	if (pci_addr_out)
 		pci_free_consistent(ioc->pdev, blk_rq_bytes(req), pci_addr_out,
-		    pci_dma_out);
-
-	if (pci_addr_in)
-		pci_free_consistent(ioc->pdev, blk_rq_bytes(rsp), pci_addr_in,
-		    pci_dma_in);
+				    pci_dma_out);
 
  out:
 	ioc->transport_cmds.status = MPT2_CMD_NOT_USED;
-- 
1.7.10.4


^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2015-01-18  6:43 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-01-18  6:41 [PATCH 0/2] Added pci_mapping_error() call and related clean up Tina Johnson
2015-01-18  6:41 ` [PATCH 1/2] drivers: scsi: mpt2sas: Added pci_dma_mapping_error() call Tina Johnson
2015-01-18  6:41 ` [PATCH 2/2] drivers: scsi: mpt2sas: Clean up error handling for calls to pci_map_single Tina Johnson

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox