Message ID | 20111007125006.7089.9539.stgit@ltc219.sdl.hitachi.co.jp |
---|---|
State | RFC, archived |
Delegated to: | David Miller |
Headers | show |
On Fri, Oct 7, 2011 at 8:50 PM, Mitsuo Hayasaka <mitsuo.hayasaka.hu@hitachi.com> wrote: > 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 <mitsuo.hayasaka.hu@hitachi.com> > Cc: Jay Vosburgh <fubar@us.ibm.com> > Cc: Andy Gospodarek <andy@greyhouse.net> Makes sense, Reviewed-by: WANG Cong <xiyou.wangcong@gmail.com> Thanks! -- 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 f1baec5..cd490b7 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
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 <mitsuo.hayasaka.hu@hitachi.com> Cc: Jay Vosburgh <fubar@us.ibm.com> Cc: Andy Gospodarek <andy@greyhouse.net> --- 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