netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jarek Poplawski <jarkao2@gmail.com>
To: Bernard Pidoux F6BVP <f6bvp@free.fr>
Cc: Bernard Pidoux <bernard.pidoux@upmc.fr>,
	Ralf Baechle DL5RB <ralf@linux-mips.org>,
	Linux Netdev List <netdev@vger.kernel.org>,
	linux-hams <linux-hams@vger.kernel.org>
Subject: Re: [AX25] kernel panic
Date: Thu, 24 Sep 2009 08:07:19 +0000	[thread overview]
Message-ID: <20090924080719.GA12279@ff.dom.local> (raw)
In-Reply-To: <4ABA9058.3010605@free.fr>

On Wed, Sep 23, 2009 at 11:17:12PM +0200, Bernard Pidoux F6BVP wrote:
> Hi Jarek,
Hi Bernard,

>
> After applying your second patch I had to wait until today before I catched
> these kernel messages.
> The last three ones where single lines.
> There was no kernel panic. 

Probably you didn't hit the some kind of traffic/problems, because
there was only some additional reporting in this patch vs. take 1.

In the meantime I found some strangeness in refcounting around
ax25_send_frame, and below is a patch which IMHO should fix it. I
don't know if it matters in your case (the previous report suggested
there should be something more), but let's try. Please, don't remove
the previous debugging patch yet, while testing this one.

Thanks,
Jarek P.
--- (ax25_send_frame patch take 1 for testing)

 include/net/netrom.h  |    2 ++
 net/ax25/ax25_out.c   |    6 ++++++
 net/netrom/nr_route.c |   11 ++++++-----
 net/rose/rose_link.c  |    8 ++++++++
 net/rose/rose_route.c |    5 +++++
 5 files changed, 27 insertions(+), 5 deletions(-)

diff --git a/include/net/netrom.h b/include/net/netrom.h
index 15696b1..ab170a6 100644
--- a/include/net/netrom.h
+++ b/include/net/netrom.h
@@ -132,6 +132,8 @@ static __inline__ void nr_node_put(struct nr_node *nr_node)
 static __inline__ void nr_neigh_put(struct nr_neigh *nr_neigh)
 {
 	if (atomic_dec_and_test(&nr_neigh->refcount)) {
+		if (nr_neigh->ax25)
+			ax25_cb_put(nr_neigh->ax25);
 		kfree(nr_neigh->digipeat);
 		kfree(nr_neigh);
 	}
diff --git a/net/ax25/ax25_out.c b/net/ax25/ax25_out.c
index bf706f8..1491260 100644
--- a/net/ax25/ax25_out.c
+++ b/net/ax25/ax25_out.c
@@ -92,6 +92,12 @@ ax25_cb *ax25_send_frame(struct sk_buff *skb, int paclen, ax25_address *src, ax2
 #endif
 	}
 
+	/*
+	 * There is one ref for the state machine; a caller needs
+	 * one more to put it back, just like with the existing one.
+	 */
+	ax25_cb_hold(ax25);
+
 	ax25_cb_add(ax25);
 
 	ax25->state = AX25_STATE_1;
diff --git a/net/netrom/nr_route.c b/net/netrom/nr_route.c
index 4eb1ac9..850ffc0 100644
--- a/net/netrom/nr_route.c
+++ b/net/netrom/nr_route.c
@@ -842,12 +842,13 @@ int nr_route_frame(struct sk_buff *skb, ax25_cb *ax25)
 	dptr  = skb_push(skb, 1);
 	*dptr = AX25_P_NETROM;
 
-	ax25s = ax25_send_frame(skb, 256, (ax25_address *)dev->dev_addr, &nr_neigh->callsign, nr_neigh->digipeat, nr_neigh->dev);
-	if (nr_neigh->ax25 && ax25s) {
-		/* We were already holding this ax25_cb */
+	ax25s = nr_neigh->ax25;
+	nr_neigh->ax25 = ax25_send_frame(skb, 256,
+					 (ax25_address *)dev->dev_addr,
+					 &nr_neigh->callsign,
+					 nr_neigh->digipeat, nr_neigh->dev);
+	if (ax25s)
 		ax25_cb_put(ax25s);
-	}
-	nr_neigh->ax25 = ax25s;
 
 	dev_put(dev);
 	ret = (nr_neigh->ax25 != NULL);
diff --git a/net/rose/rose_link.c b/net/rose/rose_link.c
index bd86a63..5ef5f69 100644
--- a/net/rose/rose_link.c
+++ b/net/rose/rose_link.c
@@ -101,13 +101,17 @@ static void rose_t0timer_expiry(unsigned long param)
 static int rose_send_frame(struct sk_buff *skb, struct rose_neigh *neigh)
 {
 	ax25_address *rose_call;
+	ax25_cb *ax25s;
 
 	if (ax25cmp(&rose_callsign, &null_ax25_address) == 0)
 		rose_call = (ax25_address *)neigh->dev->dev_addr;
 	else
 		rose_call = &rose_callsign;
 
+	ax25s = neigh->ax25;
 	neigh->ax25 = ax25_send_frame(skb, 260, rose_call, &neigh->callsign, neigh->digipeat, neigh->dev);
+	if (ax25s)
+		ax25_cb_put(ax25s);
 
 	return (neigh->ax25 != NULL);
 }
@@ -120,13 +124,17 @@ static int rose_send_frame(struct sk_buff *skb, struct rose_neigh *neigh)
 static int rose_link_up(struct rose_neigh *neigh)
 {
 	ax25_address *rose_call;
+	ax25_cb *ax25s;
 
 	if (ax25cmp(&rose_callsign, &null_ax25_address) == 0)
 		rose_call = (ax25_address *)neigh->dev->dev_addr;
 	else
 		rose_call = &rose_callsign;
 
+	ax25s = neigh->ax25;
 	neigh->ax25 = ax25_find_cb(rose_call, &neigh->callsign, neigh->digipeat, neigh->dev);
+	if (ax25s)
+		ax25_cb_put(ax25s);
 
 	return (neigh->ax25 != NULL);
 }
diff --git a/net/rose/rose_route.c b/net/rose/rose_route.c
index 9478d9b..8e5d5ac 100644
--- a/net/rose/rose_route.c
+++ b/net/rose/rose_route.c
@@ -234,6 +234,8 @@ static void rose_remove_neigh(struct rose_neigh *rose_neigh)
 
 	if ((s = rose_neigh_list) == rose_neigh) {
 		rose_neigh_list = rose_neigh->next;
+		if (rose_neigh->ax25)
+			ax25_cb_put(rose_neigh->ax25);
 		kfree(rose_neigh->digipeat);
 		kfree(rose_neigh);
 		return;
@@ -242,6 +244,8 @@ static void rose_remove_neigh(struct rose_neigh *rose_neigh)
 	while (s != NULL && s->next != NULL) {
 		if (s->next == rose_neigh) {
 			s->next = rose_neigh->next;
+			if (rose_neigh->ax25)
+				ax25_cb_put(rose_neigh->ax25);
 			kfree(rose_neigh->digipeat);
 			kfree(rose_neigh);
 			return;
@@ -814,6 +818,7 @@ void rose_link_failed(ax25_cb *ax25, int reason)
 
 	if (rose_neigh != NULL) {
 		rose_neigh->ax25 = NULL;
+		ax25_cb_put(ax25);
 
 		rose_del_route_by_neigh(rose_neigh);
 		rose_kill_by_neigh(rose_neigh);

  reply	other threads:[~2009-09-24  8:07 UTC|newest]

Thread overview: 54+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-09-21 20:11 [AX25] kernel panic Jarek Poplawski
2009-09-23 21:17 ` Bernard Pidoux F6BVP
2009-09-24  8:07   ` Jarek Poplawski [this message]
2009-09-25 13:10   ` [PATCH] ax25: Fix ax25_cb refcounting in ax25_ctl_ioctl Jarek Poplawski
2009-09-25 13:40     ` Ralf Baechle DL5RB
2009-09-25 18:35       ` Jarek Poplawski
2009-09-25 19:10         ` David Miller
2009-09-25 19:50         ` Bernard Pidoux
2009-09-25 20:29           ` Jarek Poplawski
2009-09-27  7:23         ` Ralf Baechle DL5RB
2009-09-27 17:10           ` Jarek Poplawski
2009-09-27 19:02             ` Jarek Poplawski
2009-09-27 20:57       ` [PATCH] ax25: Fix possible oops in ax25_make_new Jarek Poplawski
2009-09-28 10:47         ` Bernard Pidoux F6BVP
2009-09-30 23:44         ` David Miller
2009-09-28  7:12   ` [PATCH] ax25: Add missing dev_put in ax25_setsockopt Jarek Poplawski
2009-09-28 10:48     ` Bernard Pidoux F6BVP
2009-09-28 12:53     ` Ralf Baechle
2009-09-28 17:46       ` Bernard Pidoux
2009-09-28 19:26       ` David Miller
  -- strict thread matches above, loose matches on Subject: below --
2009-09-09 22:28 [AX25] kernel panic Bernard Pidoux
2009-09-11 19:21 ` Jarek Poplawski
2009-09-15 10:16   ` Bernard Pidoux
     [not found] ` <20090910142436.GB10547@linux-mips.org>
     [not found]   ` <4AA9288B.2070205@upmc.fr>
     [not found]     ` <20090911120557.GA12175@linux-mips.org>
2009-09-20  8:42       ` Bernard Pidoux
2009-09-20  9:09         ` f8arr
2009-09-20 21:02         ` Jarek Poplawski
2009-09-21  8:44           ` Bernard Pidoux
2008-03-18 10:44 Bernard Pidoux F6BVP
2008-03-18 21:25 ` Francois Romieu
2008-03-19  7:36   ` Bernard Pidoux F6BVP
2008-03-19 20:57     ` Bernard Pidoux
2008-03-20  7:30       ` Jarek Poplawski
2008-03-20 22:58         ` Bernard Pidoux
2008-03-21  0:28           ` Jarek Poplawski
2008-03-21  9:52             ` Bernard Pidoux
2008-03-21 11:22               ` Jarek Poplawski
2008-03-21  9:40           ` Bernard Pidoux
2008-03-22 11:36           ` Jarek Poplawski
2008-03-23 17:00             ` Bernard Pidoux
2008-03-24 20:51               ` Jarek Poplawski
2008-03-25 13:23                 ` Bernard Pidoux
2008-03-25 20:51                   ` Jarek Poplawski
2008-03-26 18:35                   ` Jarek Poplawski
2008-03-28  8:24                     ` Bernard Pidoux
2008-03-28  8:27                     ` Bernard Pidoux
2008-03-28 12:07                     ` Jarek Poplawski
2008-03-29 12:04                       ` Bernard Pidoux
2008-03-29 12:24                         ` Jarek Poplawski
2008-03-30  8:43                           ` Bernard Pidoux
2008-03-30  9:16                             ` Jarek Poplawski
2008-03-30 17:38                               ` Bernard Pidoux
2008-03-30 18:49                                 ` Jarek Poplawski
2008-03-30  9:00                           ` Bernard Pidoux
     [not found]                           ` <47EE38BA.9090500@free.fr>
     [not found]                             ` <20080329130451.GC3407@ami.dom.local>
     [not found]                               ` <47EF6479.7030702@free.fr>
     [not found]                                 ` <20080330115958.GA4975@ami.dom.local>
2008-04-01 20:37                                   ` Bernard Pidoux

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=20090924080719.GA12279@ff.dom.local \
    --to=jarkao2@gmail.com \
    --cc=bernard.pidoux@upmc.fr \
    --cc=f6bvp@free.fr \
    --cc=linux-hams@vger.kernel.org \
    --cc=netdev@vger.kernel.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).