]> err.no Git - linux-2.6/blobdiff - drivers/net/s2io.c
Fix a potential NULL pointer dereference in write_bulk_callback() in drivers/net...
[linux-2.6] / drivers / net / s2io.c
index 2d826fff7e2e9270c7dac931172ac2c726f6eae3..afef6c0c59fe3a34a70467ee60ba87cfedada12e 100644 (file)
@@ -796,12 +796,14 @@ static void free_shared_mem(struct s2io_nic *nic)
        struct mac_info *mac_control;
        struct config_param *config;
        int lst_size, lst_per_page;
-       struct net_device *dev = nic->dev;
+       struct net_device *dev;
        int page_num = 0;
 
        if (!nic)
                return;
 
+       dev = nic->dev;
+
        mac_control = &nic->mac_control;
        config = &nic->config;
 
@@ -1135,7 +1137,7 @@ static int init_nic(struct s2io_nic *nic)
         * SXE-008 TRANSMIT DMA ARBITRATION ISSUE.
         */
        if ((nic->device_type == XFRAME_I_DEVICE) &&
-               (get_xena_rev_id(nic->pdev) < 4))
+               (nic->pdev->revision < 4))
                writeq(PCC_ENABLE_FOUR, &bar0->pcc_enable);
 
        val64 = readq(&bar0->tx_fifo_partition_0);
@@ -1873,7 +1875,7 @@ static int verify_pcc_quiescent(struct s2io_nic *sp, int flag)
        herc = (sp->device_type == XFRAME_II_DEVICE);
 
        if (flag == FALSE) {
-               if ((!herc && (get_xena_rev_id(sp->pdev) >= 4)) || herc) {
+               if ((!herc && (sp->pdev->revision >= 4)) || herc) {
                        if (!(val64 & ADAPTER_STATUS_RMAC_PCC_IDLE))
                                ret = 1;
                } else {
@@ -1881,7 +1883,7 @@ static int verify_pcc_quiescent(struct s2io_nic *sp, int flag)
                                ret = 1;
                }
        } else {
-               if ((!herc && (get_xena_rev_id(sp->pdev) >= 4)) || herc) {
+               if ((!herc && (sp->pdev->revision >= 4)) || herc) {
                        if (((val64 & ADAPTER_STATUS_RMAC_PCC_IDLE) ==
                             ADAPTER_STATUS_RMAC_PCC_IDLE))
                                ret = 1;
@@ -7075,23 +7077,6 @@ static void s2io_link(struct s2io_nic * sp, int link)
        sp->start_time = jiffies;
 }
 
-/**
- *  get_xena_rev_id - to identify revision ID of xena.
- *  @pdev : PCI Dev structure
- *  Description:
- *  Function to identify the Revision ID of xena.
- *  Return value:
- *  returns the revision ID of the device.
- */
-
-static int get_xena_rev_id(struct pci_dev *pdev)
-{
-       u8 id = 0;
-       int ret;
-       ret = pci_read_config_byte(pdev, PCI_REVISION_ID, (u8 *) & id);
-       return id;
-}
-
 /**
  *  s2io_init_pci -Initialization of PCI and PCI-X configuration registers .
  *  @sp : private member of the device structure, which is a pointer to the
@@ -7550,7 +7535,7 @@ s2io_init_nic(struct pci_dev *pdev, const struct pci_device_id *pre)
        s2io_vpd_read(sp);
        DBG_PRINT(ERR_DBG, "Copyright(c) 2002-2007 Neterion Inc.\n");
        DBG_PRINT(ERR_DBG, "%s: Neterion %s (rev %d)\n",dev->name,
-                 sp->product_name, get_xena_rev_id(sp->pdev));
+                 sp->product_name, pdev->revision);
        DBG_PRINT(ERR_DBG, "%s: Driver version %s\n", dev->name,
                  s2io_driver_version);
        DBG_PRINT(ERR_DBG, "%s: MAC ADDR: "
@@ -8036,7 +8021,7 @@ static void lro_append_pkt(struct s2io_nic *sp, struct lro *lro,
 /**
  * s2io_io_error_detected - called when PCI error is detected
  * @pdev: Pointer to PCI device
- * @state: The current pci conneection state
+ * @state: The current pci connection state
  *
  * This function is called after a PCI bus error affecting
  * this device has been detected.