From patchwork Mon Oct 5 09:15:59 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johannes Berg X-Patchwork-Id: 34953 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.176.167]) by ozlabs.org (Postfix) with ESMTP id 95C11B7B91 for ; Mon, 5 Oct 2009 20:24:20 +1100 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932367AbZJEJQl (ORCPT ); Mon, 5 Oct 2009 05:16:41 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S932363AbZJEJQl (ORCPT ); Mon, 5 Oct 2009 05:16:41 -0400 Received: from xc.sipsolutions.net ([83.246.72.84]:56320 "EHLO sipsolutions.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932361AbZJEJQk (ORCPT ); Mon, 5 Oct 2009 05:16:40 -0400 Received: by sipsolutions.net with esmtpsa (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.69) (envelope-from ) id 1Mujfl-0000dE-5P; Mon, 05 Oct 2009 11:16:01 +0200 Subject: [PATCH] wext: let get_wireless_stats() sleep From: Johannes Berg To: John Linville Cc: Miles Lane , linux-wireless , netdev Date: Mon, 05 Oct 2009 11:15:59 +0200 Message-Id: <1254734159.22426.6.camel@johannes.local> Mime-Version: 1.0 X-Mailer: Evolution 2.28.0 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org A number of drivers (recently including cfg80211-based ones) assume that all wireless handlers, including statistics, can sleep and they often also implicitly assume that the rtnl is held around their invocation. This is almost always true now except when reading from sysfs: BUG: sleeping function called from invalid context at kernel/mutex.c:280 in_atomic(): 1, irqs_disabled(): 0, pid: 10450, name: head 2 locks held by head/10450: #0: (&buffer->mutex){+.+.+.}, at: [] sysfs_read_file+0x24/0xf4 #1: (dev_base_lock){++.?..}, at: [] wireless_show+0x1a/0x4c Pid: 10450, comm: head Not tainted 2.6.32-rc3 #1 Call Trace: [] __might_sleep+0xf0/0xf7 [] mutex_lock_nested+0x1a/0x33 [] wdev_lock+0xd/0xf [cfg80211] [] cfg80211_wireless_stats+0x45/0x12d [cfg80211] [] get_wireless_stats+0x16/0x1c [] wireless_show+0x2a/0x4c Fix this by using the rtnl instead of dev_base_lock. Reported-by: Miles Lane Signed-off-by: Johannes Berg --- net/core/net-sysfs.c | 4 ++-- 1 file changed, 2 insertions(+), 2 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 --- wireless-testing.orig/net/core/net-sysfs.c 2009-10-05 11:09:56.000000000 +0200 +++ wireless-testing/net/core/net-sysfs.c 2009-10-05 11:10:52.000000000 +0200 @@ -366,13 +366,13 @@ static ssize_t wireless_show(struct devi const struct iw_statistics *iw; ssize_t ret = -EINVAL; - read_lock(&dev_base_lock); + rtnl_lock(); if (dev_isalive(dev)) { iw = get_wireless_stats(dev); if (iw) ret = (*format)(iw, buf); } - read_unlock(&dev_base_lock); + rtnl_unlock(); return ret; }