From: Jeff Garzik <jgarzik@pobox.com>
To: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Francois Romieu <romieu@fr.zoreil.com>,
netdev@vger.kernel.org, Andrew Morton <akpm@osdl.org>,
Bernhard Walle <bwalle@suse.de>
Subject: Re: [PATCH] r8169: fix a race between PCI probe and dev_open
Date: Thu, 01 Feb 2007 08:04:58 -0500 [thread overview]
Message-ID: <45C1E57A.40502@pobox.com> (raw)
In-Reply-To: <Pine.LNX.4.64.0701311655050.3632@woody.linux-foundation.org>
[-- Attachment #1: Type: text/plain, Size: 1244 bytes --]
Linus Torvalds wrote:
>
> On Wed, 31 Jan 2007, Francois Romieu wrote:
>
>> Call chain:
>> -> rtl8169_init_one
>> -> register_netdev (dev_open starts to race...)
>> -> rtl8169_init_phy
>> -> rtl8169_set_speed
>> -> tp->set_speed
>> -> mod_timer(&tp->timer, ...) (if netif_running() is true)
>>
>> As netif_running() is true just before dev->open() is issued and the
>> timer is initialized during dev->open, mod_timer() meets an uninitialized
>> tp->timer and oopses.
>
> Doesn't this basically mean that *any* use of "rtl8169_set_speed()" is
> buggy?
No, just the first use, after which the one-time initialization occurs.
> Anyway, I'm going to wait for somebody smarter than me to ACK this patch.
> Jeff?
I would rather have something more like the attached patch, which
initializes the timer with the rest of the private-struct
initialization. Just like most other net drivers do.
And Herbert Xu wrote:
> Does rtl8169_init_phy need to occur after register_netdev? Normally
> register_netdev should be the very last thing in a probe routine.
Quite correct.
So... anybody wanna test my patch (didn't compile it, but it looks
right) and confirm that it fixes things?
Jeff
[-- Attachment #2: patch --]
[-- Type: text/plain, Size: 890 bytes --]
diff --git a/drivers/net/r8169.c b/drivers/net/r8169.c
index 577babd..ce66b2a 100644
--- a/drivers/net/r8169.c
+++ b/drivers/net/r8169.c
@@ -1369,11 +1369,7 @@ static inline void rtl8169_request_timer(struct net_device *dev)
(tp->phy_version >= RTL_GIGA_PHY_VER_H))
return;
- init_timer(timer);
- timer->expires = jiffies + RTL8169_PHY_TIMEOUT;
- timer->data = (unsigned long)(dev);
- timer->function = rtl8169_phy_timer;
- add_timer(timer);
+ mod_timer(timer, jiffies + RTL8169_PHY_TIMEOUT);
}
#ifdef CONFIG_NET_POLL_CONTROLLER
@@ -1686,6 +1682,10 @@ rtl8169_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
tp->mmio_addr = ioaddr;
tp->align = rtl_cfg_info[ent->driver_data].align;
+ init_timer(&tp->timer);
+ tp->timer.data = (unsigned long)(dev);
+ tp->timer.function = rtl8169_phy_timer;
+
spin_lock_init(&tp->lock);
rc = register_netdev(dev);
next prev parent reply other threads:[~2007-02-01 13:05 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-01-31 21:34 [PATCH] r8169: fix a race between PCI probe and dev_open Francois Romieu
2007-02-01 0:55 ` Linus Torvalds
2007-02-01 8:17 ` Francois Romieu
2007-02-01 13:04 ` Jeff Garzik [this message]
2007-02-01 2:40 ` Herbert Xu
2007-02-01 8:28 ` Francois Romieu
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=45C1E57A.40502@pobox.com \
--to=jgarzik@pobox.com \
--cc=akpm@osdl.org \
--cc=bwalle@suse.de \
--cc=netdev@vger.kernel.org \
--cc=romieu@fr.zoreil.com \
--cc=torvalds@linux-foundation.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).