From patchwork Thu Oct 14 02:01:52 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Neil Horman X-Patchwork-Id: 67769 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 4DDA0B6EDF for ; Thu, 14 Oct 2010 13:02:32 +1100 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754160Ab0JNCCU (ORCPT ); Wed, 13 Oct 2010 22:02:20 -0400 Received: from charlotte.tuxdriver.com ([70.61.120.58]:39922 "EHLO smtp.tuxdriver.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754153Ab0JNCCT (ORCPT ); Wed, 13 Oct 2010 22:02:19 -0400 Received: from cpe-076-182-075-229.nc.res.rr.com ([76.182.75.229] helo=localhost) by smtp.tuxdriver.com with esmtpsa (TLSv1:AES128-SHA:128) (Exim 4.63) (envelope-from ) id 1P6D97-0004CO-0Y; Wed, 13 Oct 2010 22:02:18 -0400 From: nhorman@tuxdriver.com To: netdev@vger.kernel.org Cc: bonding-devel@lists.sourceforge.net, fubar@us.ibm.com, davem@davemloft.net, andy@greyhouse.net, amwang@redhat.com, nhorman@tuxdriver.com Subject: [PATCH 4/5] Fix netconsole to not deadlock on rmmod Date: Wed, 13 Oct 2010 22:01:52 -0400 Message-Id: <1287021713-1750-5-git-send-email-nhorman@tuxdriver.com> X-Mailer: git-send-email 1.7.2.3 In-Reply-To: <1287021713-1750-1-git-send-email-nhorman@tuxdriver.com> References: <1287021713-1750-1-git-send-email-nhorman@tuxdriver.com> X-Spam-Score: -2.9 (--) X-Spam-Status: No Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org From: Neil Horman Netconsole calls netpoll_cleanup on receipt of a NETDEVICE_UNREGISTER event. The notifier subsystem calls these event handlers with rtnl_lock held, which netpoll_cleanup also takes, resulting in deadlock. Fix this by calling the __netpoll_cleanup interior function instead, and fixing up the additional pointers. Signed-off-by: Neil Horman --- drivers/net/netconsole.c | 9 ++++++++- 1 files changed, 8 insertions(+), 1 deletions(-) diff --git a/drivers/net/netconsole.c b/drivers/net/netconsole.c index ca142c4..94255f0 100644 --- a/drivers/net/netconsole.c +++ b/drivers/net/netconsole.c @@ -678,7 +678,14 @@ static int netconsole_netdev_event(struct notifier_block *this, strlcpy(nt->np.dev_name, dev->name, IFNAMSIZ); break; case NETDEV_UNREGISTER: - netpoll_cleanup(&nt->np); + /* + * rtnl_lock already held + */ + if (nt->np.dev) { + __netpoll_cleanup(&nt->np); + dev_put(nt->np.dev); + nt->np.dev = NULL; + } /* Fall through */ case NETDEV_GOING_DOWN: case NETDEV_BONDING_DESLAVE: