aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAmit Kumar Salecha <amit.salecha@qlogic.com>2010-03-25 20:30:09 -0400
committerDavid S. Miller <davem@davemloft.net>2010-03-26 14:49:22 -0400
commitafbe5cd6c40e0f20fa8832d17fa44ae605591ce1 (patch)
tree9c87278632269f839946c2f3b8039da160634ffd
parent77c553900c58c3e4f475e233ad4ff6aeb282deb4 (diff)
netxen: added sanity check for pci map
Signed-off-by: Amit Kumar Salecha <amit.salecha@qlogic.com> Return value of ioremap is not checked, NULL check added. Signed-off-by: Amit Kumar Salecha <amit.salecha@qlogic.com> Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r--drivers/net/netxen/netxen_nic_main.c45
1 files changed, 27 insertions, 18 deletions
diff --git a/drivers/net/netxen/netxen_nic_main.c b/drivers/net/netxen/netxen_nic_main.c
index 9a7a0f3c36c4..01808b28d1b6 100644
--- a/drivers/net/netxen/netxen_nic_main.c
+++ b/drivers/net/netxen/netxen_nic_main.c
@@ -604,16 +604,14 @@ netxen_cleanup_pci_map(struct netxen_adapter *adapter)
604static int 604static int
605netxen_setup_pci_map(struct netxen_adapter *adapter) 605netxen_setup_pci_map(struct netxen_adapter *adapter)
606{ 606{
607 void __iomem *mem_ptr0 = NULL;
608 void __iomem *mem_ptr1 = NULL;
609 void __iomem *mem_ptr2 = NULL;
610 void __iomem *db_ptr = NULL; 607 void __iomem *db_ptr = NULL;
611 608
612 resource_size_t mem_base, db_base; 609 resource_size_t mem_base, db_base;
613 unsigned long mem_len, db_len = 0, pci_len0 = 0; 610 unsigned long mem_len, db_len = 0;
614 611
615 struct pci_dev *pdev = adapter->pdev; 612 struct pci_dev *pdev = adapter->pdev;
616 int pci_func = adapter->ahw.pci_func; 613 int pci_func = adapter->ahw.pci_func;
614 struct netxen_hardware_context *ahw = &adapter->ahw;
617 615
618 int err = 0; 616 int err = 0;
619 617
@@ -630,24 +628,40 @@ netxen_setup_pci_map(struct netxen_adapter *adapter)
630 628
631 /* 128 Meg of memory */ 629 /* 128 Meg of memory */
632 if (mem_len == NETXEN_PCI_128MB_SIZE) { 630 if (mem_len == NETXEN_PCI_128MB_SIZE) {
633 mem_ptr0 = ioremap(mem_base, FIRST_PAGE_GROUP_SIZE); 631
634 mem_ptr1 = ioremap(mem_base + SECOND_PAGE_GROUP_START, 632 ahw->pci_base0 = ioremap(mem_base, FIRST_PAGE_GROUP_SIZE);
633 ahw->pci_base1 = ioremap(mem_base + SECOND_PAGE_GROUP_START,
635 SECOND_PAGE_GROUP_SIZE); 634 SECOND_PAGE_GROUP_SIZE);
636 mem_ptr2 = ioremap(mem_base + THIRD_PAGE_GROUP_START, 635 ahw->pci_base2 = ioremap(mem_base + THIRD_PAGE_GROUP_START,
637 THIRD_PAGE_GROUP_SIZE); 636 THIRD_PAGE_GROUP_SIZE);
638 pci_len0 = FIRST_PAGE_GROUP_SIZE; 637 if (ahw->pci_base0 == NULL || ahw->pci_base1 == NULL ||
638 ahw->pci_base2 == NULL) {
639 dev_err(&pdev->dev, "failed to map PCI bar 0\n");
640 err = -EIO;
641 goto err_out;
642 }
643
644 ahw->pci_len0 = FIRST_PAGE_GROUP_SIZE;
645
639 } else if (mem_len == NETXEN_PCI_32MB_SIZE) { 646 } else if (mem_len == NETXEN_PCI_32MB_SIZE) {
640 mem_ptr1 = ioremap(mem_base, SECOND_PAGE_GROUP_SIZE); 647
641 mem_ptr2 = ioremap(mem_base + THIRD_PAGE_GROUP_START - 648 ahw->pci_base1 = ioremap(mem_base, SECOND_PAGE_GROUP_SIZE);
649 ahw->pci_base2 = ioremap(mem_base + THIRD_PAGE_GROUP_START -
642 SECOND_PAGE_GROUP_START, THIRD_PAGE_GROUP_SIZE); 650 SECOND_PAGE_GROUP_START, THIRD_PAGE_GROUP_SIZE);
651 if (ahw->pci_base1 == NULL || ahw->pci_base2 == NULL) {
652 dev_err(&pdev->dev, "failed to map PCI bar 0\n");
653 err = -EIO;
654 goto err_out;
655 }
656
643 } else if (mem_len == NETXEN_PCI_2MB_SIZE) { 657 } else if (mem_len == NETXEN_PCI_2MB_SIZE) {
644 658
645 mem_ptr0 = pci_ioremap_bar(pdev, 0); 659 ahw->pci_base0 = pci_ioremap_bar(pdev, 0);
646 if (mem_ptr0 == NULL) { 660 if (ahw->pci_base0 == NULL) {
647 dev_err(&pdev->dev, "failed to map PCI bar 0\n"); 661 dev_err(&pdev->dev, "failed to map PCI bar 0\n");
648 return -EIO; 662 return -EIO;
649 } 663 }
650 pci_len0 = mem_len; 664 ahw->pci_len0 = mem_len;
651 } else { 665 } else {
652 return -EIO; 666 return -EIO;
653 } 667 }
@@ -656,11 +670,6 @@ netxen_setup_pci_map(struct netxen_adapter *adapter)
656 670
657 dev_info(&pdev->dev, "%dMB memory map\n", (int)(mem_len>>20)); 671 dev_info(&pdev->dev, "%dMB memory map\n", (int)(mem_len>>20));
658 672
659 adapter->ahw.pci_base0 = mem_ptr0;
660 adapter->ahw.pci_len0 = pci_len0;
661 adapter->ahw.pci_base1 = mem_ptr1;
662 adapter->ahw.pci_base2 = mem_ptr2;
663
664 if (NX_IS_REVISION_P3P(adapter->ahw.revision_id)) { 673 if (NX_IS_REVISION_P3P(adapter->ahw.revision_id)) {
665 adapter->ahw.ocm_win_crb = netxen_get_ioaddr(adapter, 674 adapter->ahw.ocm_win_crb = netxen_get_ioaddr(adapter,
666 NETXEN_PCIX_PS_REG(PCIX_OCM_WINDOW_REG(pci_func))); 675 NETXEN_PCIX_PS_REG(PCIX_OCM_WINDOW_REG(pci_func)));