IPv6: only set err in rawv6_bind() when necessary
Subsystems (2)
PATCH 1/1 IPv6: only set err in rawv6_bind() when necessary
The variable 'err' is set in rawv6_bind() before the address check fails instead of after, moved inside if() statement.
net/ipv6/raw.c +1 -1
@@ -240,10 +240,10 @@ static int rawv6_bind(struct sock *sk, s*/ v4addr =LOOPBACK4_IPV6 ;if (!(addr_type &IPV6_ADDR_MULTICAST )) { - err = -EADDRNOTAVAIL ;if (!ipv6_chk_addr (&addr->sin6_addr, dev,0 )) {if (dev)dev_put (dev); + err = -EADDRNOTAVAIL ; goto out; } }
David Miller
maintainerFrom: Brian Haley <[email protected]>
Date: Tue, 01 Aug 2006 13:06:03 -0400
Quoted 4 lines
The variable 'err' is set in
rawv6_bind()before the address check fails instead of after, moved insideif()statement.Signed-off-by Brian Haley <[email protected]>
This is a common C idiom in the kernel:
err = -EWHATEVER; if (error_condition) goto out; err = 0; out: unlock_stuff(); return err;
Every other path going from this location in rawv6_bind() will clear err to zero, so your patch also doesn't fix any bug.
Quoted 4 lines
Every other path going from this location in
rawv6_bind()will clear err to zero, so your patch also doesn't fix any bug.
I knew it didn't fix a bug, I just hadn't noticed the C idiom you pointed-out until I knew to look for it. rawv6_bind() even does this, duh.
-Brian