From patchwork Thu Feb 14 13:18:58 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Vrabel X-Patchwork-Id: 220441 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 9EA2B2C0084 for ; Fri, 15 Feb 2013 00:19:30 +1100 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S934275Ab3BNNT1 (ORCPT ); Thu, 14 Feb 2013 08:19:27 -0500 Received: from smtp.citrix.com ([66.165.176.89]:47248 "EHLO SMTP.CITRIX.COM" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1760269Ab3BNNTY (ORCPT ); Thu, 14 Feb 2013 08:19:24 -0500 X-IronPort-AV: E=Sophos;i="4.84,665,1355097600"; d="scan'208";a="7494940" Received: from accessns.citrite.net (HELO FTLPEX01CL02.citrite.net) ([10.9.154.239]) by FTLPIPO01.CITRIX.COM with ESMTP/TLS/AES128-SHA; 14 Feb 2013 13:19:23 +0000 Received: from ukmail1.uk.xensource.com (10.80.16.128) by smtprelay.citrix.com (10.13.107.79) with Microsoft SMTP Server id 14.2.318.1; Thu, 14 Feb 2013 08:19:23 -0500 Received: from qabil.uk.xensource.com ([10.80.2.76]) by ukmail1.uk.xensource.com with esmtp (Exim 4.69) (envelope-from ) id 1U5yig-00069z-PU; Thu, 14 Feb 2013 13:19:22 +0000 From: David Vrabel To: CC: David Vrabel , Konrad Rzeszutek Wilk , Ian Campbell , Jan Beulich , Wei Liu , Subject: [PATCH 2/2] xen-netback: cancel the credit timer when taking the vif down Date: Thu, 14 Feb 2013 13:18:58 +0000 Message-ID: <1360847938-11185-3-git-send-email-david.vrabel@citrix.com> X-Mailer: git-send-email 1.7.2.5 In-Reply-To: <1360847938-11185-1-git-send-email-david.vrabel@citrix.com> References: <1360847938-11185-1-git-send-email-david.vrabel@citrix.com> MIME-Version: 1.0 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org From: David Vrabel If the credit timer is left armed after calling xen_netbk_remove_xenvif(), then it may fire and attempt to schedule the vif which will then oops as vif->netbk == NULL. This may happen both in the fatal error path and during normal disconnection from the front end. The sequencing during shutdown is critical to ensure that: a) vif->netbk doesn't become unexpectedly NULL; and b) the net device/vif is not freed. 1. Mark as unschedulable (netif_carrier_off()). 2. Synchronously cancel the timer. 3. Remove the vif from the schedule list. 4. Remove it from it netback thread group. 5. Wait for vif->refcnt to become 0. Signed-off-by: David Vrabel Acked-by: Ian Campbell Reported-by: Christopher S. Aker --- drivers/net/xen-netback/interface.c | 3 +-- 1 files changed, 1 insertions(+), 2 deletions(-) diff --git a/drivers/net/xen-netback/interface.c b/drivers/net/xen-netback/interface.c index b8c5193..221f426 100644 --- a/drivers/net/xen-netback/interface.c +++ b/drivers/net/xen-netback/interface.c @@ -132,6 +132,7 @@ static void xenvif_up(struct xenvif *vif) static void xenvif_down(struct xenvif *vif) { disable_irq(vif->irq); + del_timer_sync(&vif->credit_timeout); xen_netbk_deschedule_xenvif(vif); xen_netbk_remove_xenvif(vif); } @@ -363,8 +364,6 @@ void xenvif_disconnect(struct xenvif *vif) atomic_dec(&vif->refcnt); wait_event(vif->waiting_to_free, atomic_read(&vif->refcnt) == 0); - del_timer_sync(&vif->credit_timeout); - if (vif->irq) unbind_from_irqhandler(vif->irq, vif);