All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Thibaut VARENE" <T-Bone@parisc-linux.org>
To: "Jarek Poplawski" <jarkao2@o2.pl>
Cc: "Dale Farnsworth" <dale@farnsworth.org>,
	netdev@vger.kernel.org, mlachwani@mvista.com
Subject: Re: [PATCH] Re: kernel BUG in eth_alloc_tx_desc_index at drivers/net/mv643xx_eth.c:1069!
Date: Sun, 21 Jan 2007 14:02:15 +0100	[thread overview]
Message-ID: <7d01f9f00701210502m2bb96bd8i5071a76b6a8c3ea0@mail.gmail.com> (raw)
In-Reply-To: <7d01f9f00701210418q6f506d20tdc9ce10b501370d7@mail.gmail.com>

[-- Attachment #1: Type: text/plain, Size: 980 bytes --]

On 1/21/07, Thibaut VARENE <T-Bone@parisc-linux.org> wrote:
> On 1/11/07, Jarek Poplawski <jarkao2@o2.pl> wrote:
> >
> > PS: alas I didn't even check compiling - I had no time to
> > find all compile dependencies of this driver
> > ---
> Hmm, I think this is guaranteed not to work. In between those lines
> the lock is released, while data in the mp structure is still being
> accessed. It seems that this bit of code is indeed not race-safe
> though, I'm gonna try to figure something.

This was indeed the right spot. The attached raw hack seems to fix the
bug (I couldn't crash the box so far).  I haven't checked that the
same "situation" happens elsewhere in the code, I leave that as an
exercise for the maintainers (or until I experience another kind of
crash :)

The patch is a bit ugly (printk with irq disabled will not show, etc)
but at least it does work. I'm sure somebody will figure something

HTH

T-Bone

-- 
Thibaut VARENE
http://www.parisc-linux.org/~varenet/

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: fix_mv643xx_race.patch --]
[-- Type: text/x-patch; name="fix_mv643xx_race.patch", Size: 768 bytes --]

--- linux-2.6.19.orig/drivers/net/mv643xx_eth.c	2007-01-21 13:56:04.450689123 +0100
+++ linux-2.6.19/drivers/net/mv643xx_eth.c	2007-01-21 13:39:58.228404763 +0100
@@ -312,8 +312,8 @@
 	int count;
 	int released = 0;
 
+	spin_lock_irqsave(&mp->lock, flags);
 	while (mp->tx_desc_count > 0) {
-		spin_lock_irqsave(&mp->lock, flags);
 		tx_index = mp->tx_used_desc_q;
 		desc = &mp->p_tx_desc_area[tx_index];
 		cmd_sts = desc->cmd_sts;
@@ -332,8 +332,6 @@
 		if (skb)
 			mp->tx_skb[tx_index] = NULL;
 
-		spin_unlock_irqrestore(&mp->lock, flags);
-
 		if (cmd_sts & ETH_ERROR_SUMMARY) {
 			printk("%s: Error in TX\n", dev->name);
 			mp->stats.tx_errors++;
@@ -349,6 +347,7 @@
 
 		released = 1;
 	}
+	spin_unlock_irqrestore(&mp->lock, flags);
 
 	return released;
 }

  reply	other threads:[~2007-01-21 13:02 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-01-05 19:03 kernel BUG in eth_alloc_tx_desc_index at drivers/net/mv643xx_eth.c:1069! Thibaut VARENE
2007-01-09  9:26 ` Jarek Poplawski
2007-01-09 10:27   ` Thibaut VARENE
2007-01-09 10:52     ` Jarek Poplawski
2007-01-09 10:56       ` Thibaut VARENE
2007-01-09 11:48         ` Jarek Poplawski
2007-01-09 10:57     ` Jarek Poplawski
2007-01-09 13:02     ` Jarek Poplawski
2007-01-09 17:44       ` Thibaut VARENE
2007-01-09 20:05         ` Dale Farnsworth
2007-01-09 21:05           ` Thibaut VARENE
2007-01-10 17:12             ` Thibaut VARENE
2007-01-11 10:42               ` [PATCH] " Jarek Poplawski
2007-01-21 12:18                 ` Thibaut VARENE
2007-01-21 13:02                   ` Thibaut VARENE [this message]
2007-01-22 10:02                     ` Jarek Poplawski
2007-01-22 17:06                       ` Dale Farnsworth
2007-01-23  8:17                         ` Jarek Poplawski
2007-01-23 11:52                         ` Thibaut VARENE
2007-01-23 12:42                           ` Thibaut VARENE

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=7d01f9f00701210502m2bb96bd8i5071a76b6a8c3ea0@mail.gmail.com \
    --to=t-bone@parisc-linux.org \
    --cc=dale@farnsworth.org \
    --cc=jarkao2@o2.pl \
    --cc=mlachwani@mvista.com \
    --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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.