netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Stephen Hemminger <shemminger@osdl.org>
To: Jeroen Vreeken <pe1rxq@amsat.org>
Cc: linux-hams@vger.kernel.org, ralf@linux-mips.org,
	davem@redhat.com, netdev@oss.sgi.com
Subject: [PATCH] ax25 setsockopt(SO_BINDTODEVICE) bug fix
Date: Tue, 12 Aug 2003 17:19:26 -0700	[thread overview]
Message-ID: <20030812171926.628186dc.shemminger@osdl.org> (raw)
In-Reply-To: <20030813010301.K28977@jeroen.pe1rxq.ampr.org>

Fix the error path (and indentation) in the SO_BINDTODEVICE setsockopt.
As it was, a reference to the device was left hanging, and it would
not check to see if the device was really an AX25 device.

Found this with a simple test program on 2.6.0-test3 with your rqx4 patch.

--- ax25/net/ax25/af_ax25.c	2003-08-12 17:08:42.025816088 -0700
+++ linux-2.5-net/net/ax25/af_ax25.c	2003-08-12 16:47:07.802057749 -0700
 		if (optlen > IFNAMSIZ)
 			optlen=IFNAMSIZ;
 		if (copy_from_user(devname, optval, optlen)) {
-		res = -EFAULT;
+			res = -EFAULT;
 			break;
 		}
 
@@ -650,12 +650,14 @@ static int ax25_setsockopt(struct socket
 		   (sock->state != SS_UNCONNECTED ||
 		    sk->sk_state == TCP_LISTEN)) {
 			res = -EADDRNOTAVAIL;
-			dev_put(dev);
-			break;
 		}
 
-		ax25->ax25_dev = ax25_dev_ax25dev(dev);
-		ax25_fillin_cb(ax25, ax25->ax25_dev);
+		else if ((ax25->ax25_dev = ax25_dev_ax25dev(dev)) == NULL)
+			res = -EINVAL;
+		else 
+			ax25_fillin_cb(ax25, ax25->ax25_dev);
+
+		dev_put(dev);
 		break;
 
 	default:

  parent reply	other threads:[~2003-08-13  0:19 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-08-12 17:46 [PATCH] ax25 & netrom fixes for 2.6 Jeroen Vreeken
2003-08-12 19:48 ` Stephen Hemminger
2003-08-12 20:59   ` Jeroen Vreeken
2003-08-12 20:56 ` Stephen Hemminger
2003-08-12 21:09   ` Jeroen Vreeken
2003-08-12 22:39     ` [PATCH] ax25 fix for premature free Stephen Hemminger
2003-08-12 23:03       ` Jeroen Vreeken
2003-08-12 23:49         ` [PATCH] ax25 use dev_hold/dev_put as required for net_devices Stephen Hemminger
2003-08-13  0:19         ` Stephen Hemminger [this message]
2003-08-13  0:21         ` [PATCH] Convert ax25 to seq_file Stephen Hemminger
2003-08-13 10:11           ` David S. Miller
2003-08-13 15:34             ` Jeroen Vreeken
2003-08-13 15:42               ` David S. Miller
2003-08-13 22:35                 ` [PATCH] (0/11) Netrom patches Stephen Hemminger
2003-08-15  4:13                   ` David S. Miller
2003-08-20 18:45                 ` [PATCH] ax25 changes Jeroen Vreeken
2003-08-21 19:18                   ` David S. Miller
2003-08-22 20:13                   ` [PATCH] ax25 - make sure and hold ref to dev Stephen Hemminger
2003-08-24 11:28                     ` David S. Miller
2003-08-22 20:15                   ` [RFT][PATCH] ax25 using seq_file Stephen Hemminger
2003-08-24 11:29                     ` David S. Miller
2003-08-24 22:35                       ` Jeroen Vreeken
2003-08-13 10:10     ` [PATCH] ax25 & netrom fixes for 2.6 David S. Miller

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20030812171926.628186dc.shemminger@osdl.org \
    --to=shemminger@osdl.org \
    --cc=davem@redhat.com \
    --cc=linux-hams@vger.kernel.org \
    --cc=netdev@oss.sgi.com \
    --cc=pe1rxq@amsat.org \
    --cc=ralf@linux-mips.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).