Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

net: fix smatch warnings inside datagram_poll

Commit 7d4c04fc170087119727119074e72445f2bb192b ("net: add option to enable
error queue packets waking select") has an issue due to operator precedence
causing the bit-wise OR to bind to the sock_flags call instead of the result of
the terniary conditional. This fixes the *_poll functions to work properly. The
old code results in "mask |= POLLPRI" instead of what was intended, which is to
only include POLLPRI when the socket option is enabled.

Signed-off-by: Jacob Keller <jacob.e.keller@intel.com>
Signed-off-by: David S. Miller <davem@davemloft.net>

authored by

Jacob Keller and committed by
David S. Miller
8facd5fb be0e2f1f

+5 -5
+1 -1
net/bluetooth/af_bluetooth.c
··· 423 423 424 424 if (sk->sk_err || !skb_queue_empty(&sk->sk_error_queue)) 425 425 mask |= POLLERR | 426 - sock_flag(sk, SOCK_SELECT_ERR_QUEUE) ? POLLPRI : 0; 426 + (sock_flag(sk, SOCK_SELECT_ERR_QUEUE) ? POLLPRI : 0); 427 427 428 428 if (sk->sk_shutdown & RCV_SHUTDOWN) 429 429 mask |= POLLRDHUP | POLLIN | POLLRDNORM;
+1 -1
net/core/datagram.c
··· 750 750 /* exceptional events? */ 751 751 if (sk->sk_err || !skb_queue_empty(&sk->sk_error_queue)) 752 752 mask |= POLLERR | 753 - sock_flag(sk, SOCK_SELECT_ERR_QUEUE) ? POLLPRI : 0; 753 + (sock_flag(sk, SOCK_SELECT_ERR_QUEUE) ? POLLPRI : 0); 754 754 755 755 if (sk->sk_shutdown & RCV_SHUTDOWN) 756 756 mask |= POLLRDHUP | POLLIN | POLLRDNORM;
+1 -1
net/iucv/af_iucv.c
··· 1462 1462 1463 1463 if (sk->sk_err || !skb_queue_empty(&sk->sk_error_queue)) 1464 1464 mask |= POLLERR | 1465 - sock_flag(sk, SOCK_SELECT_ERR_QUEUE) ? POLLPRI : 0; 1465 + (sock_flag(sk, SOCK_SELECT_ERR_QUEUE) ? POLLPRI : 0); 1466 1466 1467 1467 if (sk->sk_shutdown & RCV_SHUTDOWN) 1468 1468 mask |= POLLRDHUP;
+1 -1
net/nfc/llcp/sock.c
··· 522 522 523 523 if (sk->sk_err || !skb_queue_empty(&sk->sk_error_queue)) 524 524 mask |= POLLERR | 525 - sock_flag(sk, SOCK_SELECT_ERR_QUEUE) ? POLLPRI : 0; 525 + (sock_flag(sk, SOCK_SELECT_ERR_QUEUE) ? POLLPRI : 0); 526 526 527 527 if (!skb_queue_empty(&sk->sk_receive_queue)) 528 528 mask |= POLLIN | POLLRDNORM;
+1 -1
net/unix/af_unix.c
··· 2197 2197 /* exceptional events? */ 2198 2198 if (sk->sk_err || !skb_queue_empty(&sk->sk_error_queue)) 2199 2199 mask |= POLLERR | 2200 - sock_flag(sk, SOCK_SELECT_ERR_QUEUE) ? POLLPRI : 0; 2200 + (sock_flag(sk, SOCK_SELECT_ERR_QUEUE) ? POLLPRI : 0); 2201 2201 2202 2202 if (sk->sk_shutdown & RCV_SHUTDOWN) 2203 2203 mask |= POLLRDHUP | POLLIN | POLLRDNORM;