Commit db4cfd8a authored by Dhananjay Phadke's avatar Dhananjay Phadke Committed by David S. Miller

netxen: handle firmware load errors

Unwind allocations and release file firmware when
when firmware load fails.
Signed-off-by: default avatarDhananjay Phadke <dhananjay@netxen.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 6ec1c69a
...@@ -566,6 +566,9 @@ netxen_send_cmd_descs(struct netxen_adapter *adapter, ...@@ -566,6 +566,9 @@ netxen_send_cmd_descs(struct netxen_adapter *adapter,
i = 0; i = 0;
if (adapter->is_up != NETXEN_ADAPTER_UP_MAGIC)
return -EIO;
tx_ring = adapter->tx_ring; tx_ring = adapter->tx_ring;
__netif_tx_lock_bh(tx_ring->txq); __netif_tx_lock_bh(tx_ring->txq);
......
...@@ -905,6 +905,7 @@ netxen_release_firmware(struct netxen_adapter *adapter) ...@@ -905,6 +905,7 @@ netxen_release_firmware(struct netxen_adapter *adapter)
{ {
if (adapter->fw) if (adapter->fw)
release_firmware(adapter->fw); release_firmware(adapter->fw);
adapter->fw = NULL;
} }
int netxen_init_dummy_dma(struct netxen_adapter *adapter) int netxen_init_dummy_dma(struct netxen_adapter *adapter)
......
...@@ -757,7 +757,7 @@ netxen_start_firmware(struct netxen_adapter *adapter, int request_fw) ...@@ -757,7 +757,7 @@ netxen_start_firmware(struct netxen_adapter *adapter, int request_fw)
err = netxen_need_fw_reset(adapter); err = netxen_need_fw_reset(adapter);
if (err < 0) if (err < 0)
return err; goto err_out;
if (err == 0) if (err == 0)
goto wait_init; goto wait_init;
...@@ -771,7 +771,9 @@ netxen_start_firmware(struct netxen_adapter *adapter, int request_fw) ...@@ -771,7 +771,9 @@ netxen_start_firmware(struct netxen_adapter *adapter, int request_fw)
if (NX_IS_REVISION_P3(adapter->ahw.revision_id)) if (NX_IS_REVISION_P3(adapter->ahw.revision_id))
netxen_set_port_mode(adapter); netxen_set_port_mode(adapter);
netxen_load_firmware(adapter); err = netxen_load_firmware(adapter);
if (err)
goto err_out;
if (NX_IS_REVISION_P2(adapter->ahw.revision_id)) { if (NX_IS_REVISION_P2(adapter->ahw.revision_id)) {
...@@ -785,7 +787,7 @@ netxen_start_firmware(struct netxen_adapter *adapter, int request_fw) ...@@ -785,7 +787,7 @@ netxen_start_firmware(struct netxen_adapter *adapter, int request_fw)
err = netxen_init_dummy_dma(adapter); err = netxen_init_dummy_dma(adapter);
if (err) if (err)
return err; goto err_out;
/* /*
* Tell the hardware our version number. * Tell the hardware our version number.
...@@ -800,7 +802,7 @@ netxen_start_firmware(struct netxen_adapter *adapter, int request_fw) ...@@ -800,7 +802,7 @@ netxen_start_firmware(struct netxen_adapter *adapter, int request_fw)
err = netxen_phantom_init(adapter, NETXEN_NIC_PEG_TUNE); err = netxen_phantom_init(adapter, NETXEN_NIC_PEG_TUNE);
if (err) { if (err) {
netxen_free_dummy_dma(adapter); netxen_free_dummy_dma(adapter);
return err; goto err_out;
} }
nx_update_dma_mask(adapter); nx_update_dma_mask(adapter);
...@@ -808,6 +810,10 @@ netxen_start_firmware(struct netxen_adapter *adapter, int request_fw) ...@@ -808,6 +810,10 @@ netxen_start_firmware(struct netxen_adapter *adapter, int request_fw)
netxen_nic_get_firmware_info(adapter); netxen_nic_get_firmware_info(adapter);
return 0; return 0;
err_out:
netxen_release_firmware(adapter);
return err;
} }
static int static int
...@@ -876,6 +882,9 @@ netxen_nic_up(struct netxen_adapter *adapter, struct net_device *netdev) ...@@ -876,6 +882,9 @@ netxen_nic_up(struct netxen_adapter *adapter, struct net_device *netdev)
{ {
int err; int err;
if (adapter->is_up != NETXEN_ADAPTER_UP_MAGIC)
return -EIO;
err = adapter->init_port(adapter, adapter->physical_port); err = adapter->init_port(adapter, adapter->physical_port);
if (err) { if (err) {
printk(KERN_ERR "%s: Failed to initialize port %d\n", printk(KERN_ERR "%s: Failed to initialize port %d\n",
...@@ -914,6 +923,9 @@ netxen_nic_up(struct netxen_adapter *adapter, struct net_device *netdev) ...@@ -914,6 +923,9 @@ netxen_nic_up(struct netxen_adapter *adapter, struct net_device *netdev)
static void static void
netxen_nic_down(struct netxen_adapter *adapter, struct net_device *netdev) netxen_nic_down(struct netxen_adapter *adapter, struct net_device *netdev)
{ {
if (adapter->is_up != NETXEN_ADAPTER_UP_MAGIC)
return;
spin_lock(&adapter->tx_clean_lock); spin_lock(&adapter->tx_clean_lock);
netif_carrier_off(netdev); netif_carrier_off(netdev);
netif_tx_disable(netdev); netif_tx_disable(netdev);
......
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