aboutsummaryrefslogtreecommitdiffstats
path: root/net/packet/af_packet.c
diff options
context:
space:
mode:
authorWillem de Bruijn <willemb@google.com>2015-05-14 15:25:02 -0400
committerDavid S. Miller <davem@davemloft.net>2015-05-14 17:40:54 -0400
commit54d7c01d3ed699cfc213115eaecfe1175cfaff8f (patch)
treea3549400cc77b55a19ea400a3f6623f461739139 /net/packet/af_packet.c
parent4ffd3c730e7ba2eb53a427f1a2bba2eec5f2d97b (diff)
packet: fix warnings in rollover lock contention
Avoid two xchg calls whose return values were unused, causing a warning on some architectures. The relevant variable is a hint and read without mutual exclusion. This fix makes all writers hold the receive_queue lock. Suggested-by: David S. Miller <davem@davemloft.net> Signed-off-by: Willem de Bruijn <willemb@google.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/packet/af_packet.c')
-rw-r--r--net/packet/af_packet.c15
1 files changed, 5 insertions, 10 deletions
diff --git a/net/packet/af_packet.c b/net/packet/af_packet.c
index 31d58565726c..c30d14781576 100644
--- a/net/packet/af_packet.c
+++ b/net/packet/af_packet.c
@@ -1301,17 +1301,12 @@ static int packet_rcv_has_room(struct packet_sock *po, struct sk_buff *skb)
1301 int ret; 1301 int ret;
1302 bool has_room; 1302 bool has_room;
1303 1303
1304 if (po->prot_hook.func == tpacket_rcv) { 1304 spin_lock_bh(&po->sk.sk_receive_queue.lock);
1305 spin_lock(&po->sk.sk_receive_queue.lock); 1305 ret = __packet_rcv_has_room(po, skb);
1306 ret = __packet_rcv_has_room(po, skb);
1307 spin_unlock(&po->sk.sk_receive_queue.lock);
1308 } else {
1309 ret = __packet_rcv_has_room(po, skb);
1310 }
1311
1312 has_room = ret == ROOM_NORMAL; 1306 has_room = ret == ROOM_NORMAL;
1313 if (po->pressure == has_room) 1307 if (po->pressure == has_room)
1314 xchg(&po->pressure, !has_room); 1308 po->pressure = !has_room;
1309 spin_unlock_bh(&po->sk.sk_receive_queue.lock);
1315 1310
1316 return ret; 1311 return ret;
1317} 1312}
@@ -3814,7 +3809,7 @@ static unsigned int packet_poll(struct file *file, struct socket *sock,
3814 mask |= POLLIN | POLLRDNORM; 3809 mask |= POLLIN | POLLRDNORM;
3815 } 3810 }
3816 if (po->pressure && __packet_rcv_has_room(po, NULL) == ROOM_NORMAL) 3811 if (po->pressure && __packet_rcv_has_room(po, NULL) == ROOM_NORMAL)
3817 xchg(&po->pressure, 0); 3812 po->pressure = 0;
3818 spin_unlock_bh(&sk->sk_receive_queue.lock); 3813 spin_unlock_bh(&sk->sk_receive_queue.lock);
3819 spin_lock_bh(&sk->sk_write_queue.lock); 3814 spin_lock_bh(&sk->sk_write_queue.lock);
3820 if (po->tx_ring.pg_vec) { 3815 if (po->tx_ring.pg_vec) {