Commit 013068fa authored by Bhanu Prakash Gollapudi's avatar Bhanu Prakash Gollapudi Committed by James Bottomley

[SCSI] bnx2fc: Fix panic caused because of incorrect errror handling in create().

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: default avatarBhanu Prakash Gollapudi <bprakash@broadcom.com>
Signed-off-by: default avatarJames Bottomley <JBottomley@Parallels.com>
parent 0cbf32e1
...@@ -1441,6 +1441,14 @@ static struct fc_lport *bnx2fc_if_create(struct bnx2fc_interface *interface, ...@@ -1441,6 +1441,14 @@ static struct fc_lport *bnx2fc_if_create(struct bnx2fc_interface *interface,
return NULL; 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) static void bnx2fc_interface_cleanup(struct bnx2fc_interface *interface)
{ {
struct fc_lport *lport = interface->ctlr.lp; struct fc_lport *lport = interface->ctlr.lp;
...@@ -1453,10 +1461,7 @@ static void bnx2fc_interface_cleanup(struct bnx2fc_interface *interface) ...@@ -1453,10 +1461,7 @@ static void bnx2fc_interface_cleanup(struct bnx2fc_interface *interface)
/* Free existing transmit skbs */ /* Free existing transmit skbs */
fcoe_clean_pending_queue(lport); fcoe_clean_pending_queue(lport);
/* Dont listen for Ethernet packets anymore */ bnx2fc_net_cleanup(interface);
__dev_remove_pack(&interface->fcoe_packet_type);
__dev_remove_pack(&interface->fip_packet_type);
synchronize_net();
bnx2fc_free_vport(hba, lport); bnx2fc_free_vport(hba, lport);
} }
...@@ -1991,7 +1996,6 @@ static int bnx2fc_create(struct net_device *netdev, enum fip_state fip_mode) ...@@ -1991,7 +1996,6 @@ static int bnx2fc_create(struct net_device *netdev, enum fip_state fip_mode)
if (!lport) { if (!lport) {
printk(KERN_ERR PFX "Failed to create interface (%s)\n", printk(KERN_ERR PFX "Failed to create interface (%s)\n",
netdev->name); netdev->name);
bnx2fc_interface_cleanup(interface);
rc = -EINVAL; rc = -EINVAL;
goto if_create_err; goto if_create_err;
} }
...@@ -2026,6 +2030,7 @@ static int bnx2fc_create(struct net_device *netdev, enum fip_state fip_mode) ...@@ -2026,6 +2030,7 @@ static int bnx2fc_create(struct net_device *netdev, enum fip_state fip_mode)
if_create_err: if_create_err:
destroy_workqueue(interface->timer_work_queue); destroy_workqueue(interface->timer_work_queue);
ifput_err: ifput_err:
bnx2fc_net_cleanup(interface);
bnx2fc_interface_put(interface); bnx2fc_interface_put(interface);
netdev_err: netdev_err:
module_put(THIS_MODULE); module_put(THIS_MODULE);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment