net/sunrpc/svcsock.c: fix a check
Subsystems (3)
PATCH 1/1 net/sunrpc/svcsock.c: fix a check
The return value of kernel_recvmsg() should be assigned to "err", not compared with the random value of a never initialized "err" (and the "< 0" check wrongly always returned false since == comparisons never have a result < 0).
Spotted by the Coverity checker.
---
net/sunrpc/svcsock.c renamed from net/sunrpc/svcsock.c.old +2 -2
@@ -779,8 +779,8 @@ svc_udp_recvfrom(struct svc_rqst *rqstp) }clear_bit (SK_DATA , &svsk->sk_flags); -while ((err ==kernel_recvmsg (svsk->sk_sock, &msg,NULL , -0 ,0 ,MSG_PEEK |MSG_DONTWAIT )) <0 || +while ((err =kernel_recvmsg (svsk->sk_sock, &msg,NULL , +0 ,0 ,MSG_PEEK |MSG_DONTWAIT )) <0 || (skb =skb_recv_datagram (svsk->sk_sk,0 ,1 , &err)) ==NULL ) {if (err == -EAGAIN ) {svc_sock_received (svsk);
Quoted 13 lines · On Mon, 19 Mar 2007 10:33:42 +0100 Adrian Bunk <[email protected]> wrote:
The return value of
kernel_recvmsg()should be assigned to "err", not compared with the random value of a never initialized "err" (and the "< 0" check wrongly always returned false since == comparisons never have a result < 0).Spotted by the Coverity checker.
Signed-off-by Adrian Bunk <[email protected]>---
net/sunrpc/svcsock.c svc_udp_recvfrom(struct svc_rqst *rqstp) · line 786
Quoted 10 lines
net/sunrpc/svcsock.c renamed from net/sunrpc/svcsock.c.old +2
-2@@ -779,8 +779,8 @@ svc_udp_recvfrom(struct svc_rqst *rqstp) }clear_bit (SK_DATA , &svsk->sk_flags); -while ((err ==kernel_recvmsg (svsk->sk_sock, &msg,NULL , -0 ,0 ,MSG_PEEK |MSG_DONTWAIT )) <0 || +while ((err =kernel_recvmsg (svsk->sk_sock, &msg,NULL , +0 ,0 ,MSG_PEEK |MSG_DONTWAIT )) <0 || (skb =skb_recv_datagram (svsk->sk_sk,0 ,1 , &err)) ==NULL ) {if (err == -EAGAIN ) {svc_sock_received (svsk);
Cute. The compiler must have decided to apply the "(a==b) can never be less than zero" optimisation before performing uninitialised variable analysis.
Neil, this one needs runtime testing before we can apply it to 2.6.21, I think.
-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT & business topics through brief surveys-and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
NFS maillist - [email protected]
https://lists.sourceforge.net/lists/listinfo/nfs