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