Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp173143imu; Thu, 8 Nov 2018 17:11:49 -0800 (PST) X-Google-Smtp-Source: AJdET5eJb2N8TD79NqqpZ0geG6roOYNgGt4RSO2BCWvqMocM5xClQdWrXyaz81QjzcPcT5uvVJoc X-Received: by 2002:a63:ae4d:: with SMTP id e13-v6mr5743832pgp.315.1541725909262; Thu, 08 Nov 2018 17:11:49 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1541725909; cv=none; d=google.com; s=arc-20160816; b=F6okxZqLSY+42adtk415KWzNp7DQVCw42LkCkc6tw1edcax5HRphttnXjqZ2W0cVz1 thuAwgfaaClzokjP2QTNS6lsJ7XjHCFTikFjBeAow0oHMOpQorFi08uAlk4aIdErPIlj /futsb8R88nuYAOWeGfpmi2RbJL/7+ZKTjwUhyTciBUUZSz5Qh5ehL3g0hzmIOxNEOua ZgZLsanGGsHFj+zOSqw5wJog1ypqMlHptgFzJFtmdgeMMp5yNxb0O5eujW5IglQwykcK lljub5Eg273MMlti8GGh5UaZyPLRlrVh2Mhs/NStUXCyNzHbauE8UNt3sF9o66YWI0VF 6EzQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :dkim-signature; bh=eVTwJ6ChUDGYX2iDKW1/ywBewnaUyN2dWZrdpD930e4=; b=pLRHQF/Kjp2vfn2Eedhggt0Ovwf+WF/QRrSp9Zk75VrM6x1pdm20DXFVbnhj4/ZgR7 5o1ByTDYa+SS9csLwKiF0WzKlJsUrJ6HiVrQVycvk1XqPLJrn/R44WCbhi5cVBvNFS2T W8278/DUtv18ID80z7z/qF+1WXtenhBn1Osoh5u7vsaRVrt2t17wUfi9oqo8/Nj3iQby DpfcBP936A3Kd3UjE3SpSXZ/sl69PgxlO59RKtNrMXulQaJXxEec5rX5h/HRLwrG/Lwa 0oYPv6iHhGiZgwGB8ojfA3eikHzotnvcWm3x3Y5ylFvd1cX+VwPorD6LK2wi15tvASMN DWfQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2018-07-02 header.b=kbY6k3E8; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=oracle.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 31-v6si5928529plc.140.2018.11.08.17.11.34; Thu, 08 Nov 2018 17:11:49 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2018-07-02 header.b=kbY6k3E8; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=oracle.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727534AbeKIKsL (ORCPT + 99 others); Fri, 9 Nov 2018 05:48:11 -0500 Received: from aserp2120.oracle.com ([141.146.126.78]:60966 "EHLO aserp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727231AbeKIKsK (ORCPT ); Fri, 9 Nov 2018 05:48:10 -0500 Received: from pps.filterd (aserp2120.oracle.com [127.0.0.1]) by aserp2120.oracle.com (8.16.0.22/8.16.0.22) with SMTP id wA918v5l194260; Fri, 9 Nov 2018 01:09:46 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id; s=corp-2018-07-02; bh=eVTwJ6ChUDGYX2iDKW1/ywBewnaUyN2dWZrdpD930e4=; b=kbY6k3E8GqNEZcRCxiuDNNwV3uJfkICaUgBBsvBzISub4DL5Z+RCQDGYmg2Xrj6IvSWI eqI0n0DDbSdY/fjKetYRJoTHTGK2IB/0Arbx2DRFa7Q4QcTK1WE6z74CFbErJHG6N7p3 ZR9W0U8ycrNJl8QNZKbHYq5KAQZHCyXIiPSP/Ye9odiRoWXuGBotejcIorGwH89KOW8c g9IElf9yC9hrow/9vsk193KdZmnXdjMOgnkitjdYsAOTGX9pHwBe7qIBa5Xngy7tcvKZ dNWTFGA4PvaEVFd2cf415yNjiJCfsKBl7p8bCbcMItjmJ+NzbOJ+9/iFbMOfqoX2pjnD LQ== Received: from aserv0021.oracle.com (aserv0021.oracle.com [141.146.126.233]) by aserp2120.oracle.com with ESMTP id 2nh3mq4men-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 09 Nov 2018 01:09:46 +0000 Received: from userv0121.oracle.com (userv0121.oracle.com [156.151.31.72]) by aserv0021.oracle.com (8.14.4/8.14.4) with ESMTP id wA919jmo012132 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 9 Nov 2018 01:09:45 GMT Received: from abhmp0002.oracle.com (abhmp0002.oracle.com [141.146.116.8]) by userv0121.oracle.com (8.14.4/8.13.8) with ESMTP id wA919icb024541; Fri, 9 Nov 2018 01:09:44 GMT Received: from manjunathpatil.us.oracle.com (/10.211.44.52) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Thu, 08 Nov 2018 17:09:44 -0800 From: Manjunath Patil To: boris.ostrovsky@oracle.com, jgross@suse.com, konrad.wilk@oracle.com, roger.pau@citrix.com Cc: axboe@kernel.dk, xen-devel@lists.xenproject.org, linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, stable@vger.kernel.org Subject: [PATCH v2] xen-blkfront: fix kernel panic with blkfront_remove() Date: Thu, 8 Nov 2018 17:10:43 -0800 Message-Id: <1541725843-2019-1-git-send-email-manjunath.b.patil@oracle.com> X-Mailer: git-send-email 1.7.1 X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=9071 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=2 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=916 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1807170000 definitions=main-1811090009 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org When we try to detach the device, blkfront_remove() tries to access blkfront_info leading to kernel panic. Typical call stack involving panic - #10 page_fault at ffffffff816f25df [exception RIP: blkif_free+46] #11 blkfront_remove at ffffffffa004de47 [xen_blkfront] #12 xenbus_dev_remove at ffffffff813faa4c #13 __device_release_driver at ffffffff814769aa #14 device_release_driver at ffffffff81476a63 #15 bus_remove_device at ffffffff814762eb #16 device_del at ffffffff81472684 #17 device_unregister at ffffffff814727e2 #18 xenbus_dev_changed at ffffffff813fa89f #19 frontend_changed at ffffffff813fca19 #20 xenwatch_thread at ffffffff813f88f9 #21 kthread at ffffffff810a486b #22 ret_from_fork at ffffffff816ed2a8 Cc: stable@vger.kernel.org Signed-off-by: Manjunath Patil --- v2: style change. added the missing space b/w if and ( --- drivers/block/xen-blkfront.c | 3 +++ 1 files changed, 3 insertions(+), 0 deletions(-) diff --git a/drivers/block/xen-blkfront.c b/drivers/block/xen-blkfront.c index dc8fe25..2d8b10d 100644 --- a/drivers/block/xen-blkfront.c +++ b/drivers/block/xen-blkfront.c @@ -2496,6 +2496,9 @@ static int blkfront_remove(struct xenbus_device *xbdev) dev_dbg(&xbdev->dev, "%s removed", xbdev->nodename); + if (!info) + return 0; + blkif_free(info, 0); mutex_lock(&info->mutex); -- 1.7.1