netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Ralf Baechle <ralf@linux-mips.org>
To: "David S. Miller" <davem@davemloft.net>
Cc: netdev@vger.kernel.org, linux-hams@vger.kernel.org,
	Ralf Baechle <ralf@linux-mips.org>
Subject: [AX.25 3/7] Fix unchecked ax25_listen_register uses
Date: Thu, 14 Dec 2006 23:42:09 +0100	[thread overview]
Message-ID: <11661361342916-git-send-email-ralf@linux-mips.org> (raw)
In-Reply-To: <11661361331883-git-send-email-ralf@linux-mips.org>

Fix ax25_listen_register to return something that's a sane error code,
then all callers to use it.

Signed-off-by: Ralf Baechle <ralf@linux-mips.org>

 net/ax25/ax25_iface.c |    7 ++++---
 net/netrom/nr_dev.c   |   24 ++++++++++++++++++------
 net/rose/af_rose.c    |    3 ++-
 3 files changed, 24 insertions(+), 10 deletions(-)

Index: linux-net/net/ax25/ax25_iface.c
===================================================================
--- linux-net.orig/net/ax25/ax25_iface.c
+++ linux-net/net/ax25/ax25_iface.c
@@ -154,7 +154,7 @@ int ax25_listen_register(ax25_address *c
 		return 0;
 
 	if ((listen = kmalloc(sizeof(*listen), GFP_ATOMIC)) == NULL)
-		return 0;
+		return -ENOMEM;
 
 	listen->callsign = *callsign;
 	listen->dev      = dev;
@@ -164,7 +164,7 @@ int ax25_listen_register(ax25_address *c
 	listen_list  = listen;
 	spin_unlock_bh(&listen_lock);
 
-	return 1;
+	return 0;
 }
 
 EXPORT_SYMBOL(ax25_listen_register);
@@ -225,7 +225,8 @@ int ax25_listen_mine(ax25_address *calls
 
 	spin_lock_bh(&listen_lock);
 	for (listen = listen_list; listen != NULL; listen = listen->next)
-		if (ax25cmp(&listen->callsign, callsign) == 0 && (listen->dev == dev || listen->dev == NULL)) {
+		if (ax25cmp(&listen->callsign, callsign) == 0 &&
+		    (listen->dev == dev || listen->dev == NULL)) {
 			spin_unlock_bh(&listen_lock);
 			return 1;
 	}
Index: linux-net/net/netrom/nr_dev.c
===================================================================
--- linux-net.orig/net/netrom/nr_dev.c
+++ linux-net/net/netrom/nr_dev.c
@@ -128,25 +128,37 @@ static int nr_header(struct sk_buff *skb
 	return -37;
 }
 
-static int nr_set_mac_address(struct net_device *dev, void *addr)
+static int __must_check nr_set_mac_address(struct net_device *dev, void *addr)
 {
 	struct sockaddr *sa = addr;
+	int err;
+
+	if (!memcmp(dev->dev_addr, sa->sa_data, dev->addr_len))
+		return 0;
+
+	if (dev->flags & IFF_UP) {
+		err = ax25_listen_register((ax25_address *)sa->sa_data, NULL);
+		if (err)
+			return err;
 
-	if (dev->flags & IFF_UP)
 		ax25_listen_release((ax25_address *)dev->dev_addr, NULL);
+	}
 
 	memcpy(dev->dev_addr, sa->sa_data, dev->addr_len);
 
-	if (dev->flags & IFF_UP)
-		ax25_listen_register((ax25_address *)dev->dev_addr, NULL);
-
 	return 0;
 }
 
 static int nr_open(struct net_device *dev)
 {
+	int err;
+
+	err = ax25_listen_register((ax25_address *)dev->dev_addr, NULL);
+	if (err)
+		return err;
+
 	netif_start_queue(dev);
-	ax25_listen_register((ax25_address *)dev->dev_addr, NULL);
+
 	return 0;
 }
 
Index: linux-net/net/rose/af_rose.c
===================================================================
--- linux-net.orig/net/rose/af_rose.c
+++ linux-net/net/rose/af_rose.c
@@ -1314,7 +1314,8 @@ static int rose_ioctl(struct socket *soc
 		if (copy_from_user(&rose_callsign, argp, sizeof(ax25_address)))
 			return -EFAULT;
 		if (ax25cmp(&rose_callsign, &null_ax25_address) != 0)
-			ax25_listen_register(&rose_callsign, NULL);
+			return ax25_listen_register(&rose_callsign, NULL);
+
 		return 0;
 
 	case SIOCRSGL2CALL:

  parent reply	other threads:[~2006-12-14 22:42 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-12-14 22:42 [AX.25 1/7] Mark all kmalloc users __must_check Ralf Baechle
2006-12-14 22:42 ` [AX.25 2/7] Fix unchecked ax25_protocol_register uses Ralf Baechle
2006-12-14 23:52   ` David Miller
2006-12-14 22:42 ` Ralf Baechle [this message]
2006-12-14 23:52   ` [AX.25 3/7] Fix unchecked ax25_listen_register uses David Miller
2006-12-14 22:42 ` [AX.25 4/7] Fix unchecked nr_add_node uses Ralf Baechle
2006-12-14 23:52   ` David Miller
2006-12-14 22:42 ` [AX.25 5/7] Fix unchecked ax25_linkfail_register uses Ralf Baechle
2006-12-14 23:53   ` David Miller
2006-12-14 22:42 ` [AX.25 6/7] Fix unchecked rose_add_loopback_node uses Ralf Baechle
2006-12-14 23:53   ` David Miller
2006-12-14 22:42 ` [AX.25 7/7] Fix unchecked rose_add_loopback_neigh uses Ralf Baechle
2006-12-14 23:53   ` David Miller
2006-12-14 23:52 ` [AX.25 1/7] Mark all kmalloc users __must_check David 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=11661361342916-git-send-email-ralf@linux-mips.org \
    --to=ralf@linux-mips.org \
    --cc=davem@davemloft.net \
    --cc=linux-hams@vger.kernel.org \
    --cc=netdev@vger.kernel.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).