patch-2.4.19 linux-2.4.19/net/netrom/af_netrom.c

Next file: linux-2.4.19/net/netrom/nr_loopback.c
Previous file: linux-2.4.19/net/netlink/netlink_dev.c
Back to the patch index
Back to the overall index

diff -urN linux-2.4.18/net/netrom/af_netrom.c linux-2.4.19/net/netrom/af_netrom.c
@@ -31,7 +31,9 @@
  *	NET/ROM 007	Jonathan(G4KLX)	New timer architecture.
  *					Impmented Idle timer.
  *			Arnaldo C. Melo s/suser/capable/, micro cleanups
- *			Jeroen (PE1RXQ)	Use sock_orphan() on release.
+ *			Jeroen(PE1RXQ)	Use sock_orphan() on release.
+ *			Tomi(OH2BNS)	Better frame type checking.
+ *					Device refcnt fixes.
  */
 
 #include <linux/config.h>
@@ -128,6 +130,7 @@
 
 	if ((s = nr_list) == sk) {
 		nr_list = s->next;
+		dev_put(sk->protinfo.nr->device);
 		restore_flags(flags);
 		return;
 	}
@@ -135,6 +138,7 @@
 	while (s != NULL && s->next != NULL) {
 		if (s->next == sk) {
 			s->next = sk->next;
+			dev_put(sk->protinfo.nr->device);
 			restore_flags(flags);
 			return;
 		}
@@ -616,16 +620,20 @@
 	 * Only the super user can set an arbitrary user callsign.
 	 */
 	if (addr->fsa_ax25.sax25_ndigis == 1) {
-		if (!capable(CAP_NET_BIND_SERVICE))
+		if (!capable(CAP_NET_BIND_SERVICE)) {
+			dev_put(dev);
 			return -EACCES;
+		}
 		sk->protinfo.nr->user_addr   = addr->fsa_digipeater[0];
 		sk->protinfo.nr->source_addr = addr->fsa_ax25.sax25_call;
 	} else {
 		source = &addr->fsa_ax25.sax25_call;
 
 		if ((user = ax25_findbyuid(current->euid)) == NULL) {
-			if (ax25_uid_policy && !capable(CAP_NET_BIND_SERVICE))
+			if (ax25_uid_policy && !capable(CAP_NET_BIND_SERVICE)) {
+				dev_put(dev);
 				return -EPERM;
+			}
 			user = source;
 		}
 
@@ -680,8 +688,10 @@
 		source = (ax25_address *)dev->dev_addr;
 
 		if ((user = ax25_findbyuid(current->euid)) == NULL) {
-			if (ax25_uid_policy && !capable(CAP_NET_ADMIN))
+			if (ax25_uid_policy && !capable(CAP_NET_ADMIN)) {
+				dev_put(dev);
 				return -EPERM;
+			}
 			user = source;
 		}
 
@@ -976,6 +986,8 @@
 	sk->ack_backlog++;
 	make->pair = sk;
 
+	dev_hold(make->protinfo.nr->device);
+
 	nr_insert_socket(make);
 
 	skb_queue_head(&sk->receive_queue, skb);
@@ -1336,6 +1348,7 @@
 
 MODULE_AUTHOR("Jonathan Naylor G4KLX <g4klx@g4klx.demon.co.uk>");
 MODULE_DESCRIPTION("The amateur radio NET/ROM network and transport layer protocol");
+MODULE_LICENSE("GPL");
 
 static void __exit nr_exit(void)
 {
@@ -1364,7 +1377,6 @@
 			dev_nr[i].priv = NULL;
 			unregister_netdev(&dev_nr[i]);
 		}
-		kfree(dev_nr[i].name);
 	}
 
 	kfree(dev_nr);

FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen (who was at: slshen@lbl.gov)