netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] IPv6: only set err in rawv6_bind() when necessary
@ 2006-08-01 17:06 Brian Haley
  2006-08-01 22:03 ` David Miller
  0 siblings, 1 reply; 3+ messages in thread
From: Brian Haley @ 2006-08-01 17:06 UTC (permalink / raw)
  To: David Miller; +Cc: netdev

[-- Attachment #1: Type: text/plain, Size: 170 bytes --]

The variable 'err' is set in rawv6_bind() before the address check fails 
instead of after, moved inside if() statement.

Signed-off-by: Brian Haley <brian.haley@hp.com>

[-- Attachment #2: raw.patch --]
[-- Type: text/x-patch, Size: 425 bytes --]

diff --git a/net/ipv6/raw.c b/net/ipv6/raw.c
index 8a30cd8..072b28b 100644
--- a/net/ipv6/raw.c
+++ b/net/ipv6/raw.c
@@ -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;
 			}
 		}

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] IPv6: only set err in rawv6_bind() when necessary
  2006-08-01 17:06 [PATCH] IPv6: only set err in rawv6_bind() when necessary Brian Haley
@ 2006-08-01 22:03 ` David Miller
  2006-08-02 16:04   ` Brian Haley
  0 siblings, 1 reply; 3+ messages in thread
From: David Miller @ 2006-08-01 22:03 UTC (permalink / raw)
  To: brian.haley; +Cc: netdev

From: Brian Haley <brian.haley@hp.com>
Date: Tue, 01 Aug 2006 13:06:03 -0400

> The variable 'err' is set in rawv6_bind() before the address check fails 
> instead of after, moved inside if() statement.
> 
> Signed-off-by: Brian Haley <brian.haley@hp.com>

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.

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] IPv6: only set err in rawv6_bind() when necessary
  2006-08-01 22:03 ` David Miller
@ 2006-08-02 16:04   ` Brian Haley
  0 siblings, 0 replies; 3+ messages in thread
From: Brian Haley @ 2006-08-02 16:04 UTC (permalink / raw)
  To: David Miller; +Cc: netdev


> 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

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2006-08-02 16:04 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-08-01 17:06 [PATCH] IPv6: only set err in rawv6_bind() when necessary Brian Haley
2006-08-01 22:03 ` David Miller
2006-08-02 16:04   ` Brian Haley

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).