linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Petr Vandrovec <vandrove@vc.cvut.cz>
To: davem@redhat.com
Cc: acme@conectiva.com.br, linux-kernel@vger.kernel.org
Subject: [PATCH] Unloading of psnap
Date: Mon, 22 Jul 2002 23:28:47 +0200	[thread overview]
Message-ID: <20020722212847.GA1391@vana.vc.cvut.cz> (raw)
In-Reply-To: <20020722194814.GA1668@vana.vc.cvut.cz>

Hi Dave,
  during my work on removing cli/sti from these two files I found that
removing psnap causes kernel to crash because of it does not unregister
from 802.2 layer.

  While I was on it, I also added MOD_INC_USE_COUNT/MOD_DEC_USE_COUNT
into both 802.2 and SNAP. It is not strictly required as all callers
should have reference by name to register_*_client function, but I do not 
think that MOD_*_USE_COUNT will slow code down, and now it is directly 
visible how many snap and 802.2 clients live on system. And I'm sure
that somebody could through inter_module_get arrange some call path
so that we could unload p8022/psnap while still having some clients
registered.
					Thanks,
						Petr Vandrovec
						vandrove@vc.cvut.cz

diff linux-2.5.27-c683/net/802/p8022.c.orig linux-2.5.27-c683/net/802/p8022.c
--- linux-2.5.27-c683/net/802/p8022.c.orig	2002-07-22 21:32:20.000000000 +0200
+++ linux-2.5.27-c683/net/802/p8022.c	2002-07-22 23:12:43.000000000 +0200
@@ -95,6 +95,7 @@
 		goto out;
 	proto = kmalloc(sizeof(*proto), GFP_ATOMIC);
 	if (proto) {
+		MOD_INC_USE_COUNT;
 		proto->type[0]		= type;
 		proto->type_len		= 1;
 		proto->rcvfunc		= rcvfunc;
@@ -121,6 +122,7 @@
 			*clients = tmp->next;
 			kfree(tmp);
 			llc_unregister_sap(type);
+			MOD_DEC_USE_COUNT;
 			break;
 		}
 		clients = &tmp->next;
diff linux-2.5.27-c683/net/802/psnap.c.orig linux-2.5.27-c683/net/802/psnap.c
--- linux-2.5.27-c683/net/802/psnap.c.orig	2002-07-22 21:52:11.000000000 +0200
+++ linux-2.5.27-c683/net/802/psnap.c	2002-07-22 23:14:34.000000000 +0200
@@ -103,7 +103,14 @@
 		printk("SNAP - unable to register with 802.2\n");
 	return 0;
 }
+
+static void __exit snap_exit(void)
+{
+	unregister_8022_client(0xAA);
+}
+
 module_init(snap_init);
+module_exit(snap_exit);
 
 /*
  *	Register SNAP clients. We don't yet use this for IP.
@@ -121,6 +128,7 @@
 	proto = (struct datalink_proto *) kmalloc(sizeof(*proto), GFP_ATOMIC);
 	if (proto != NULL)
 	{
+		MOD_INC_USE_COUNT;
 		memcpy(proto->type, desc,5);
 		proto->type_len = 5;
 		proto->rcvfunc = rcvfunc;
@@ -152,6 +160,7 @@
 		{
 			*clients = tmp->next;
 			kfree(tmp);
+			MOD_DEC_USE_COUNT;
 			break;
 		}
 		else

  parent reply	other threads:[~2002-07-22 21:26 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-07-22 19:48 [PATCH] cli/sti in net/802/* Petr Vandrovec
2002-07-22 19:59 ` Petr Vandrovec
2002-07-22 21:28 ` Petr Vandrovec [this message]
2002-07-23  2:07 ` 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=20020722212847.GA1391@vana.vc.cvut.cz \
    --to=vandrove@vc.cvut.cz \
    --cc=acme@conectiva.com.br \
    --cc=davem@redhat.com \
    --cc=linux-kernel@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).