LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
* [2.6.21 patch] net/sunrpc/svcsock.c: fix a check
@ 2007-03-19 9:33 Adrian Bunk
2007-03-20 7:38 ` Andrew Morton
0 siblings, 1 reply; 2+ messages in thread
From: Adrian Bunk @ 2007-03-19 9:33 UTC (permalink / raw)
To: Neil Brown; +Cc: nfs, linux-kernel
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 <bunk@stusta.de>
---
--- linux-2.6.21-rc3-mm2/net/sunrpc/svcsock.c.old 2007-03-19 09:44:40.000000000 +0100
+++ linux-2.6.21-rc3-mm2/net/sunrpc/svcsock.c 2007-03-19 09:45:18.000000000 +0100
@@ -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);
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [2.6.21 patch] net/sunrpc/svcsock.c: fix a check
2007-03-19 9:33 [2.6.21 patch] net/sunrpc/svcsock.c: fix a check Adrian Bunk
@ 2007-03-20 7:38 ` Andrew Morton
0 siblings, 0 replies; 2+ messages in thread
From: Andrew Morton @ 2007-03-20 7:38 UTC (permalink / raw)
To: Adrian Bunk; +Cc: Neil Brown, nfs, linux-kernel
On Mon, 19 Mar 2007 10:33:42 +0100 Adrian Bunk <bunk@stusta.de> 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 <bunk@stusta.de>
>
> ---
> --- linux-2.6.21-rc3-mm2/net/sunrpc/svcsock.c.old 2007-03-19 09:44:40.000000000 +0100
> +++ linux-2.6.21-rc3-mm2/net/sunrpc/svcsock.c 2007-03-19 09:45:18.000000000 +0100
> @@ -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.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2007-03-20 7:41 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-03-19 9:33 [2.6.21 patch] net/sunrpc/svcsock.c: fix a check Adrian Bunk
2007-03-20 7:38 ` Andrew Morton
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).