From patchwork Mon May 16 14:46:47 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kalle Valo X-Patchwork-Id: 95761 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 C24ABB6EF1 for ; Tue, 17 May 2011 00:50:53 +1000 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755766Ab1EPOus (ORCPT ); Mon, 16 May 2011 10:50:48 -0400 Received: from emh05.mail.saunalahti.fi ([62.142.5.111]:57784 "EHLO emh05.mail.saunalahti.fi" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755870Ab1EPOqw (ORCPT ); Mon, 16 May 2011 10:46:52 -0400 Received: from saunalahti-vams (vs3-11.mail.saunalahti.fi [62.142.5.95]) by emh05-2.mail.saunalahti.fi (Postfix) with SMTP id 052768C198; Mon, 16 May 2011 17:46:51 +0300 (EEST) Received: from emh05.mail.saunalahti.fi ([62.142.5.111]) by vs3-11.mail.saunalahti.fi ([62.142.5.95]) with SMTP (gateway) id A049B8F4166; Mon, 16 May 2011 17:46:50 +0300 Received: from localhost6.localdomain6 (a88-115-184-248.elisa-laajakaista.fi [88.115.184.248]) by emh05.mail.saunalahti.fi (Postfix) with ESMTP id C6B4F27D86; Mon, 16 May 2011 17:46:47 +0300 (EEST) Subject: [PATCH v3 2/2] net: postpone net device uevent to fix a race To: netdev@vger.kernel.org From: Kalle Valo Cc: linux-wireless@vger.kernel.org, linux-kernel@vger.kernel.org Date: Mon, 16 May 2011 17:46:47 +0300 Message-ID: <20110516144647.13838.40897.stgit@localhost6.localdomain6> In-Reply-To: <20110516143913.13838.85357.stgit@localhost6.localdomain6> References: <20110516143913.13838.85357.stgit@localhost6.localdomain6> 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 udev 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 So the kobject is visible in udev before the device is ready. The issue is reported here: https://bugzilla.kernel.org/show_bug.cgi?id=15606 Fix this by postponing the uevent with device_add_noevent() and calling device_uevent() once the device is really ready. Thanks to Johannes Berg for the original idea. Signed-off-by: Kalle Valo --- net/core/dev.c | 3 +++ net/core/net-sysfs.c | 2 +- 2 files changed, 4 insertions(+), 1 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 856b6ee..80cfa23 100644 --- a/net/core/dev.c +++ b/net/core/dev.c @@ -5454,6 +5454,9 @@ int register_netdevice(struct net_device *dev) rollback_registered(dev); dev->reg_state = NETREG_UNREGISTERED; } + + device_uevent(&(dev->dev)); + /* * Prevent userspace races by waiting until the network * device is fully setup before sending notifications. diff --git a/net/core/net-sysfs.c b/net/core/net-sysfs.c index 5ceb257..c10b1d5 100644 --- a/net/core/net-sysfs.c +++ b/net/core/net-sysfs.c @@ -1337,7 +1337,7 @@ int netdev_register_kobject(struct net_device *net) #endif #endif /* CONFIG_SYSFS */ - error = device_add(dev); + error = device_add_noevent(dev); if (error) return error;