[PATCH NEXT 7/8] qlcnic: protect resource access

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
From: Amit Kumar Salecha
Date: Thursday, April 22, 2010 - 5:51 am

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>
---
 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 bfc5510..ee573fe 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)
 	struct qlcnic_host_sds_ring *sds_ring;
 	struct qlcnic_recv_context *recv_ctx = &adapter->recv_ctx;
 
+	if (adapter->is_up != QLCNIC_ADAPTER_UP_MAGIC)
+		return;
+
 	for (ring = 0; ring < adapter->max_sds_rings; ring++) {
 		sds_ring = &recv_ctx->sds_rings[ring];
 		napi_enable(&sds_ring->napi);
@@ -222,6 +225,9 @@ qlcnic_napi_disable(struct qlcnic_adapter *adapter)
 	struct qlcnic_host_sds_ring *sds_ring;
 	struct qlcnic_recv_context *recv_ctx = &adapter->recv_ctx;
 
+	if (adapter->is_up != QLCNIC_ADAPTER_UP_MAGIC)
+		return;
+
 	for (ring = 0; ring < adapter->max_sds_rings; ring++) {
 		sds_ring = &recv_ctx->sds_rings[ring];
 		qlcnic_disable_int(sds_ring);
@@ -1573,6 +1579,11 @@ qlcnic_xmit_frame(struct sk_buff *skb, struct net_device *netdev)
 	int frag_count, no_of_desc;
 	u32 num_txd = tx_ring->num_desc;
 
+	if (!test_bit(__QLCNIC_DEV_UP, &adapter->state)) {
+		netif_stop_queue(netdev);
+		return NETDEV_TX_BUSY;
+	}
+
 	frag_count = skb_shinfo(skb)->nr_frags + 1;
 
 	/* 4 fragments per cmd des */
-- 
1.6.0.2

--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
[PATCH NEXT 0/8]qlcnic: inter driver coexistence fixes, Amit Kumar Salecha, (Thu Apr 22, 5:51 am)
[PATCH NEXT 1/8] qlcnic: additional driver statistics, Amit Kumar Salecha, (Thu Apr 22, 5:51 am)
[PATCH NEXT 2/8] qlcnic: fix defines as per IDC document, Amit Kumar Salecha, (Thu Apr 22, 5:51 am)
[PATCH NEXT 3/8] qlcnic: fix fw initialization responsibility, Amit Kumar Salecha, (Thu Apr 22, 5:51 am)
[PATCH NEXT 6/8] qlcnic: fix rcv buffer leak, Amit Kumar Salecha, (Thu Apr 22, 5:51 am)
[PATCH NEXT 7/8] qlcnic: protect resource access, Amit Kumar Salecha, (Thu Apr 22, 5:51 am)
[PATCH NEXT 8/8] qlcnic: update version 5.0.2, Amit Kumar Salecha, (Thu Apr 22, 5:51 am)