]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
bnx2fc: Fix panic caused because of incorrect errror handling in create().
authorBhanu Prakash Gollapudi <bprakash@broadcom.com>
Tue, 30 Aug 2011 22:54:52 +0000 (15:54 -0700)
committerJoe Jin <joe.jin@oracle.com>
Thu, 17 May 2012 01:36:49 +0000 (09:36 +0800)
Driver incorrectly calls bnx2fc_interface_cleanup() when bnx2fc_if_create fails
which accesses bad pointer. Handle bnx2fc_if_create failure by directly calling
bnx2fc_net_cleanup.

Signed-off-by: Bhanu Prakash Gollapudi <bprakash@broadcom.com>
Signed-off-by: James Bottomley <JBottomley@Parallels.com>
(cherry picked from commit 013068fa6f65f7037adedc141fbd27afc99ab1bb)

Signed-off-by: Joe Jin <joe.jin@oracle.com>
drivers/scsi/bnx2fc/bnx2fc_fcoe.c

index 3741dc8f42be135fec2f8146a53619bc27c5669f..2efad412003ea37a5c7fcb4fc5fd10e14fa378fe 100644 (file)
@@ -1442,6 +1442,14 @@ free_blport:
        return NULL;
 }
 
+static void bnx2fc_net_cleanup(struct bnx2fc_interface *interface)
+{
+       /* Dont listen for Ethernet packets anymore */
+       __dev_remove_pack(&interface->fcoe_packet_type);
+       __dev_remove_pack(&interface->fip_packet_type);
+       synchronize_net();
+}
+
 static void bnx2fc_interface_cleanup(struct bnx2fc_interface *interface)
 {
        struct fc_lport *lport = interface->ctlr.lp;
@@ -1454,10 +1462,7 @@ static void bnx2fc_interface_cleanup(struct bnx2fc_interface *interface)
        /* Free existing transmit skbs */
        fcoe_clean_pending_queue(lport);
 
-       /* Dont listen for Ethernet packets anymore */
-       __dev_remove_pack(&interface->fcoe_packet_type);
-       __dev_remove_pack(&interface->fip_packet_type);
-       synchronize_net();
+       bnx2fc_net_cleanup(interface);
 
        bnx2fc_free_vport(hba, lport);
 }
@@ -1992,7 +1997,6 @@ static int bnx2fc_create(struct net_device *netdev, enum fip_state fip_mode)
        if (!lport) {
                printk(KERN_ERR PFX "Failed to create interface (%s)\n",
                        netdev->name);
-               bnx2fc_interface_cleanup(interface);
                rc = -EINVAL;
                goto if_create_err;
        }
@@ -2027,6 +2031,7 @@ static int bnx2fc_create(struct net_device *netdev, enum fip_state fip_mode)
 if_create_err:
        destroy_workqueue(interface->timer_work_queue);
 ifput_err:
+       bnx2fc_net_cleanup(interface);
        bnx2fc_interface_put(interface);
 netdev_err:
        module_put(THIS_MODULE);