linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] scsi: bfa: add error handling for pci_iomap
@ 2018-06-11  8:26 Zhouyang Jia
  2018-06-14 11:57 ` [PATCH v2] " Zhouyang Jia
  0 siblings, 1 reply; 3+ messages in thread
From: Zhouyang Jia @ 2018-06-11  8:26 UTC (permalink / raw)
  Cc: Zhouyang Jia, Anil Gurumurthy, Sudarsana Kalluru,
	James E.J. Bottomley, Martin K. Petersen, linux-scsi,
	linux-kernel

When pci_iomap fails, the lack of error-handling code may
cause unexpected results.

This patch adds error-handling code after calling pci_iomap.

Signed-off-by: Zhouyang Jia <jiazhouyang09@gmail.com>
---
 drivers/scsi/bfa/bfad.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/drivers/scsi/bfa/bfad.c b/drivers/scsi/bfa/bfad.c
index bd7e6a6f..74e39d7 100644
--- a/drivers/scsi/bfa/bfad.c
+++ b/drivers/scsi/bfa/bfad.c
@@ -760,6 +760,11 @@ bfad_pci_init(struct pci_dev *pdev, struct bfad_s *bfad)
 		goto out_release_region;
 	}
 
+	if (bfad->pci_bar2_kva == NULL) {
+		printk(KERN_ERR "Fail to map bar2\n");
+		goto out_release_region;
+	}
+
 	bfad->hal_pcidev.pci_slot = PCI_SLOT(pdev->devfn);
 	bfad->hal_pcidev.pci_func = PCI_FUNC(pdev->devfn);
 	bfad->hal_pcidev.pci_bar_kva = bfad->pci_bar0_kva;
-- 
2.7.4

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

* [PATCH v2] scsi: bfa: add error handling for pci_iomap
  2018-06-11  8:26 [PATCH] scsi: bfa: add error handling for pci_iomap Zhouyang Jia
@ 2018-06-14 11:57 ` Zhouyang Jia
  2018-06-14 12:00   ` Andy Shevchenko
  0 siblings, 1 reply; 3+ messages in thread
From: Zhouyang Jia @ 2018-06-14 11:57 UTC (permalink / raw)
  Cc: Zhouyang Jia, Anil Gurumurthy, Sudarsana Kalluru,
	James E.J. Bottomley, Martin K. Petersen, linux-scsi,
	linux-kernel

When pci_iomap fails, the lack of error-handling code may
cause unexpected results.

This patch adds error-handling code after calling pci_iomap.

Signed-off-by: Zhouyang Jia <jiazhouyang09@gmail.com>
---
v1->v2:
- Unmap bfad->pci_bar0_kva.
---
 drivers/scsi/bfa/bfad.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/drivers/scsi/bfa/bfad.c b/drivers/scsi/bfa/bfad.c
index bd7e6a6f..693e180 100644
--- a/drivers/scsi/bfa/bfad.c
+++ b/drivers/scsi/bfa/bfad.c
@@ -760,6 +760,11 @@ bfad_pci_init(struct pci_dev *pdev, struct bfad_s *bfad)
 		goto out_release_region;
 	}
 
+	if (bfad->pci_bar2_kva == NULL) {
+		printk(KERN_ERR "Fail to map bar2\n");
+		goto out_unmap_bar0;
+	}
+
 	bfad->hal_pcidev.pci_slot = PCI_SLOT(pdev->devfn);
 	bfad->hal_pcidev.pci_func = PCI_FUNC(pdev->devfn);
 	bfad->hal_pcidev.pci_bar_kva = bfad->pci_bar0_kva;
@@ -797,6 +802,8 @@ bfad_pci_init(struct pci_dev *pdev, struct bfad_s *bfad)
 
 	return 0;
 
+out_unmap_bar0:
+	pci_iounmap(pdev, bfad->pci_bar0_kva);
 out_release_region:
 	pci_release_regions(pdev);
 out_disable_device:
-- 
2.7.4


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

* Re: [PATCH v2] scsi: bfa: add error handling for pci_iomap
  2018-06-14 11:57 ` [PATCH v2] " Zhouyang Jia
@ 2018-06-14 12:00   ` Andy Shevchenko
  0 siblings, 0 replies; 3+ messages in thread
From: Andy Shevchenko @ 2018-06-14 12:00 UTC (permalink / raw)
  To: Zhouyang Jia
  Cc: Anil Gurumurthy, Sudarsana Kalluru, James E.J. Bottomley,
	Martin K. Petersen, linux-scsi, Linux Kernel Mailing List

On Thu, Jun 14, 2018 at 2:57 PM, Zhouyang Jia <jiazhouyang09@gmail.com> wrote:
> When pci_iomap fails, the lack of error-handling code may
> cause unexpected results.

What results?
How had you tested it?

> This patch adds error-handling code after calling pci_iomap.

> +       if (bfad->pci_bar2_kva == NULL) {

> +               printk(KERN_ERR "Fail to map bar2\n");

pr_err() ?

> +               goto out_unmap_bar0;
> +       }

-- 
With Best Regards,
Andy Shevchenko

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

end of thread, other threads:[~2018-06-14 12:00 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-06-11  8:26 [PATCH] scsi: bfa: add error handling for pci_iomap Zhouyang Jia
2018-06-14 11:57 ` [PATCH v2] " Zhouyang Jia
2018-06-14 12:00   ` Andy Shevchenko

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).