From patchwork Fri Apr 29 17:26:34 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kalle Valo X-Patchwork-Id: 93469 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 4436D1007E8 for ; Sat, 30 Apr 2011 03:36:57 +1000 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1760407Ab1D2Rgx (ORCPT ); Fri, 29 Apr 2011 13:36:53 -0400 Received: from emh06.mail.saunalahti.fi ([62.142.5.116]:47934 "EHLO emh06.mail.saunalahti.fi" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1757894Ab1D2Rgw (ORCPT ); Fri, 29 Apr 2011 13:36:52 -0400 X-Greylist: delayed 609 seconds by postgrey-1.27 at vger.kernel.org; Fri, 29 Apr 2011 13:36:52 EDT Received: from saunalahti-vams (vs3-12.mail.saunalahti.fi [62.142.5.96]) by emh06-2.mail.saunalahti.fi (Postfix) with SMTP id 0A7E0C7D77; Fri, 29 Apr 2011 20:26:42 +0300 (EEST) Received: from emh03.mail.saunalahti.fi ([62.142.5.109]) by vs3-12.mail.saunalahti.fi ([62.142.5.96]) with SMTP (gateway) id A06A0DDE918; Fri, 29 Apr 2011 20:26:41 +0300 Received: from [127.0.1.1] (a88-115-184-248.elisa-laajakaista.fi [88.115.184.248]) by emh03.mail.saunalahti.fi (Postfix) with ESMTP id DC2F2158A66; Fri, 29 Apr 2011 20:26:38 +0300 (EEST) Subject: [PATCH] net: fix rtnl even race in register_netdevice() To: netdev@vger.kernel.org From: Kalle Valo Cc: linux-wireless@vger.kernel.org Date: Fri, 29 Apr 2011 20:26:34 +0300 Message-ID: <20110429172634.27130.25375.stgit@x201> User-Agent: StGit/0.15 MIME-Version: 1.0 X-Antivirus: VAMS Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org From: Kalle Valo There's a race in register_netdevice so that the rtnl event is sent before the device is actually ready. This was visible with flimflam, chrome os connection manager: 00:21:35 roska flimflamd[2598]: src/udev.c:add_net_device() 00:21:35 roska flimflamd[2598]: connman_inet_ifname: SIOCGIFNAME(index 4): No such device 00:21:45 roska flimflamd[2598]: src/rtnl.c:rtnl_message() buf 0xbfefda3c len 1004 00:21:45 roska flimflamd[2598]: src/rtnl.c:rtnl_message() NEWLINK len 1004 type 16 flags 0x0000 seq 0 So the kobject is visible in udev before the device is ready. (ignore the 10 s delay, I added that to reproduce the issue easily) The issue is reported here: https://bugzilla.kernel.org/show_bug.cgi?id=15606 The fix is to call netdev_register_kobject() after the device is added to the list. Signed-off-by: Kalle Valo --- net/core/dev.c | 10 +++++----- 1 files changed, 5 insertions(+), 5 deletions(-) -- To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/net/core/dev.c b/net/core/dev.c index 956d3b0..f2afbe6 100644 --- a/net/core/dev.c +++ b/net/core/dev.c @@ -5425,11 +5425,6 @@ int register_netdevice(struct net_device *dev) if (ret) goto err_uninit; - ret = netdev_register_kobject(dev); - if (ret) - goto err_uninit; - dev->reg_state = NETREG_REGISTERED; - netdev_update_features(dev); /* @@ -5443,6 +5438,11 @@ int register_netdevice(struct net_device *dev) dev_hold(dev); list_netdevice(dev); + ret = netdev_register_kobject(dev); + if (ret) + goto err_uninit; + dev->reg_state = NETREG_REGISTERED; + /* Notify protocols, that a new device appeared. */ ret = call_netdevice_notifiers(NETDEV_REGISTER, dev); ret = notifier_to_errno(ret);