p54: fix race condition in memory management

This patch fixes a number of race conditions in the driver.
Up until now, "entry" pointer was initialized before acquiring the right lock.

Signed-off-by: Christian Lamparter <chunkeey@web.de>
Signed-off-by: John W. Linville <linville@tuxdriver.com>

authored by Christian Lamparter and committed by John W. Linville c0350024 bd05f28e

+6 -3
+6 -3
drivers/net/wireless/p54/p54common.c
··· 710 __le32 req_id) 711 { 712 struct p54_common *priv = dev->priv; 713 - struct sk_buff *entry = priv->tx_queue.next; 714 unsigned long flags; 715 716 spin_lock_irqsave(&priv->tx_queue.lock, flags); 717 while (entry != (struct sk_buff *)&priv->tx_queue) { 718 struct p54_hdr *hdr = (struct p54_hdr *) entry->data; 719 ··· 733 struct p54_common *priv = dev->priv; 734 struct p54_hdr *hdr = (struct p54_hdr *) skb->data; 735 struct p54_frame_sent *payload = (struct p54_frame_sent *) hdr->data; 736 - struct sk_buff *entry = (struct sk_buff *) priv->tx_queue.next; 737 u32 addr = le32_to_cpu(hdr->req_id) - priv->headroom; 738 struct memrecord *range = NULL; 739 u32 freed = 0; ··· 742 int count, idx; 743 744 spin_lock_irqsave(&priv->tx_queue.lock, flags); 745 while (entry != (struct sk_buff *)&priv->tx_queue) { 746 struct ieee80211_tx_info *info = IEEE80211_SKB_CB(entry); 747 struct p54_hdr *entry_hdr; ··· 978 struct p54_hdr *data, u32 len) 979 { 980 struct p54_common *priv = dev->priv; 981 - struct sk_buff *entry = priv->tx_queue.next; 982 struct sk_buff *target_skb = NULL; 983 struct ieee80211_tx_info *info; 984 struct memrecord *range; ··· 1016 } 1017 } 1018 1019 while (left--) { 1020 u32 hole_size; 1021 info = IEEE80211_SKB_CB(entry);
··· 710 __le32 req_id) 711 { 712 struct p54_common *priv = dev->priv; 713 + struct sk_buff *entry; 714 unsigned long flags; 715 716 spin_lock_irqsave(&priv->tx_queue.lock, flags); 717 + entry = priv->tx_queue.next; 718 while (entry != (struct sk_buff *)&priv->tx_queue) { 719 struct p54_hdr *hdr = (struct p54_hdr *) entry->data; 720 ··· 732 struct p54_common *priv = dev->priv; 733 struct p54_hdr *hdr = (struct p54_hdr *) skb->data; 734 struct p54_frame_sent *payload = (struct p54_frame_sent *) hdr->data; 735 + struct sk_buff *entry; 736 u32 addr = le32_to_cpu(hdr->req_id) - priv->headroom; 737 struct memrecord *range = NULL; 738 u32 freed = 0; ··· 741 int count, idx; 742 743 spin_lock_irqsave(&priv->tx_queue.lock, flags); 744 + entry = (struct sk_buff *) priv->tx_queue.next; 745 while (entry != (struct sk_buff *)&priv->tx_queue) { 746 struct ieee80211_tx_info *info = IEEE80211_SKB_CB(entry); 747 struct p54_hdr *entry_hdr; ··· 976 struct p54_hdr *data, u32 len) 977 { 978 struct p54_common *priv = dev->priv; 979 + struct sk_buff *entry; 980 struct sk_buff *target_skb = NULL; 981 struct ieee80211_tx_info *info; 982 struct memrecord *range; ··· 1014 } 1015 } 1016 1017 + entry = priv->tx_queue.next; 1018 while (left--) { 1019 u32 hole_size; 1020 info = IEEE80211_SKB_CB(entry);