diff options
author | Amit Kumar Salecha <amit.salecha@qlogic.com> | 2010-04-21 22:51:41 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2010-04-22 18:28:31 -0400 |
commit | 780ab790f5099727baff6fa056bba6c5c7c2587a (patch) | |
tree | 7d49abe211e17afec4337c8b1aaf0ca7be7edfc5 | |
parent | ed6f1353e195b4432e251667b2d84d766d07c79c (diff) |
qlcnic: protect resource access
We do netif_device_attach, even if resource allocation fails.
Driver callbacks can be called, if device is attached.
All these callbacks need to be protected by ADAPTER_UP_MAGIC check.
Signed-off-by: Amit Kumar Salecha <amit.salecha@qlogic.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r-- | drivers/net/qlcnic/qlcnic_main.c | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/drivers/net/qlcnic/qlcnic_main.c b/drivers/net/qlcnic/qlcnic_main.c index bfc551029537..ee573fe52a8e 100644 --- a/drivers/net/qlcnic/qlcnic_main.c +++ b/drivers/net/qlcnic/qlcnic_main.c | |||
@@ -208,6 +208,9 @@ qlcnic_napi_enable(struct qlcnic_adapter *adapter) | |||
208 | struct qlcnic_host_sds_ring *sds_ring; | 208 | struct qlcnic_host_sds_ring *sds_ring; |
209 | struct qlcnic_recv_context *recv_ctx = &adapter->recv_ctx; | 209 | struct qlcnic_recv_context *recv_ctx = &adapter->recv_ctx; |
210 | 210 | ||
211 | if (adapter->is_up != QLCNIC_ADAPTER_UP_MAGIC) | ||
212 | return; | ||
213 | |||
211 | for (ring = 0; ring < adapter->max_sds_rings; ring++) { | 214 | for (ring = 0; ring < adapter->max_sds_rings; ring++) { |
212 | sds_ring = &recv_ctx->sds_rings[ring]; | 215 | sds_ring = &recv_ctx->sds_rings[ring]; |
213 | napi_enable(&sds_ring->napi); | 216 | napi_enable(&sds_ring->napi); |
@@ -222,6 +225,9 @@ qlcnic_napi_disable(struct qlcnic_adapter *adapter) | |||
222 | struct qlcnic_host_sds_ring *sds_ring; | 225 | struct qlcnic_host_sds_ring *sds_ring; |
223 | struct qlcnic_recv_context *recv_ctx = &adapter->recv_ctx; | 226 | struct qlcnic_recv_context *recv_ctx = &adapter->recv_ctx; |
224 | 227 | ||
228 | if (adapter->is_up != QLCNIC_ADAPTER_UP_MAGIC) | ||
229 | return; | ||
230 | |||
225 | for (ring = 0; ring < adapter->max_sds_rings; ring++) { | 231 | for (ring = 0; ring < adapter->max_sds_rings; ring++) { |
226 | sds_ring = &recv_ctx->sds_rings[ring]; | 232 | sds_ring = &recv_ctx->sds_rings[ring]; |
227 | qlcnic_disable_int(sds_ring); | 233 | qlcnic_disable_int(sds_ring); |
@@ -1573,6 +1579,11 @@ qlcnic_xmit_frame(struct sk_buff *skb, struct net_device *netdev) | |||
1573 | int frag_count, no_of_desc; | 1579 | int frag_count, no_of_desc; |
1574 | u32 num_txd = tx_ring->num_desc; | 1580 | u32 num_txd = tx_ring->num_desc; |
1575 | 1581 | ||
1582 | if (!test_bit(__QLCNIC_DEV_UP, &adapter->state)) { | ||
1583 | netif_stop_queue(netdev); | ||
1584 | return NETDEV_TX_BUSY; | ||
1585 | } | ||
1586 | |||
1576 | frag_count = skb_shinfo(skb)->nr_frags + 1; | 1587 | frag_count = skb_shinfo(skb)->nr_frags + 1; |
1577 | 1588 | ||
1578 | /* 4 fragments per cmd des */ | 1589 | /* 4 fragments per cmd des */ |