From patchwork Wed Oct 19 08:17:57 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mitsuo Hayasaka X-Patchwork-Id: 120571 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 D5C0BB6F94 for ; Wed, 19 Oct 2011 19:13:02 +1100 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755581Ab1JSIMm (ORCPT ); Wed, 19 Oct 2011 04:12:42 -0400 Received: from mail7.hitachi.co.jp ([133.145.228.42]:34451 "EHLO mail7.hitachi.co.jp" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755565Ab1JSIMi (ORCPT ); Wed, 19 Oct 2011 04:12:38 -0400 Received: from mlsv5.hitachi.co.jp (unknown [133.144.234.166]) by mail7.hitachi.co.jp (Postfix) with ESMTP id E0BA237AC3; Wed, 19 Oct 2011 17:12:36 +0900 (JST) Received: from mfilter04.hitachi.co.jp by mlsv5.hitachi.co.jp (8.13.1/8.13.1) id p9J8Cav0019750; Wed, 19 Oct 2011 17:12:36 +0900 Received: from vshuts3.hitachi.co.jp (vshuts3.hitachi.co.jp [10.201.6.72]) by mfilter04.hitachi.co.jp (Switch-3.3.4/Switch-3.3.4) with ESMTP id p9J8CZqc023196; Wed, 19 Oct 2011 17:12:36 +0900 X-AuditID: b753bd60-9fe84ba000000655-12-4e9e867374a4 Received: from hsdlmain.sdl.hitachi.co.jp (unknown [133.144.14.194]) by vshuts3.hitachi.co.jp (Symantec Mail Security) with ESMTP id A61337741E3; Wed, 19 Oct 2011 17:12:35 +0900 (JST) Received: from hsdlvgate2.sdl.hitachi.co.jp by hsdlmain.sdl.hitachi.co.jp (8.13.1/3.7W11021512) id p9J8CYiX030426; Wed, 19 Oct 2011 17:12:34 +0900 X-AuditID: b753bd60-9fe84ba000000655-12-4e9e867374a4 Received: from sdl99w.sdl.hitachi.co.jp (sdl99w.sdl.hitachi.co.jp [133.144.14.250]) by hsdlvgate2.sdl.hitachi.co.jp (Symantec Mail Security) with ESMTP id C5A9E236562; Wed, 19 Oct 2011 17:12:34 +0900 (JST) Received: from ltc219.sdl.hitachi.co.jp (cb10033149.sdl.hitachi.co.jp [10.232.10.18]) by sdl99w.sdl.hitachi.co.jp (Postfix) with ESMTP id 247611254B5; Wed, 19 Oct 2011 17:12:33 +0900 (JST) From: Mitsuo Hayasaka Subject: [PATCH net -v2] [BUGFIX] bonding: use flush_delayed_work_sync in bond_close To: Jay Vosburgh , Andy Gospodarek Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, yrl.pp-manager.tt@hitachi.com, Mitsuo Hayasaka , Jay Vosburgh , Andy Gospodarek , WANG Cong Date: Wed, 19 Oct 2011 17:17:57 +0900 Message-ID: <20111019081757.12455.24788.stgit@ltc219.sdl.hitachi.co.jp> User-Agent: StGIT/0.14.3 MIME-Version: 1.0 X-Brightmail-Tracker: AAAAAA== Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org The bond_close() calls cancel_delayed_work() to cancel delayed works. It, however, cannot cancel works that were already queued in workqueue. The bond_open() initializes work->data, and proccess_one_work() refers get_work_cwq(work)->wq->flags. The get_work_cwq() returns NULL when work->data has been initialized. Thus, a panic occurs. This patch uses flush_delayed_work_sync() instead of cancel_delayed_work() in bond_close(). It cancels delayed timer and waits for work to finish execution. So, it can avoid the null pointer dereference due to the parallel executions of proccess_one_work() and initializing proccess of bond_open(). Signed-off-by: Mitsuo Hayasaka Reviewed-by: WANG Cong Cc: Jay Vosburgh Cc: Andy Gospodarek Cc: WANG Cong --- drivers/net/bonding/bond_main.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/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c index de3d351..a4353f9 100644 --- a/drivers/net/bonding/bond_main.c +++ b/drivers/net/bonding/bond_main.c @@ -3504,27 +3504,27 @@ static int bond_close(struct net_device *bond_dev) write_unlock_bh(&bond->lock); if (bond->params.miimon) { /* link check interval, in milliseconds. */ - cancel_delayed_work(&bond->mii_work); + flush_delayed_work_sync(&bond->mii_work); } if (bond->params.arp_interval) { /* arp interval, in milliseconds. */ - cancel_delayed_work(&bond->arp_work); + flush_delayed_work_sync(&bond->arp_work); } switch (bond->params.mode) { case BOND_MODE_8023AD: - cancel_delayed_work(&bond->ad_work); + flush_delayed_work_sync(&bond->ad_work); break; case BOND_MODE_TLB: case BOND_MODE_ALB: - cancel_delayed_work(&bond->alb_work); + flush_delayed_work_sync(&bond->alb_work); break; default: break; } if (delayed_work_pending(&bond->mcast_work)) - cancel_delayed_work(&bond->mcast_work); + flush_delayed_work_sync(&bond->mcast_work); if (bond_is_lb(bond)) { /* Must be called only after all