Received: by 2002:a25:7ec1:0:0:0:0:0 with SMTP id z184csp768033ybc; Sat, 16 Nov 2019 08:20:46 -0800 (PST) X-Google-Smtp-Source: APXvYqw0/RX4MdZITAOTVrfiN1EM6y1kT8TQlPqrMQO8npQaVa5t9gOG0EEz48kujEN1lMFt1csx X-Received: by 2002:a5d:6104:: with SMTP id v4mr20525820wrt.36.1573921246584; Sat, 16 Nov 2019 08:20:46 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1573921246; cv=none; d=google.com; s=arc-20160816; b=KvaAVRDQMpleLZ3/kfjwUq8Vxkf+yD7J2KHqnUgI8e8CZxp0iddw2N3IUKQBfrPh2H VWUqX9w+F7SyLt02UZWQMCXkUOwNQ3A7hUXZqNg3qavmKXvXykbBQxhTHm8NspArOIie zJw71T8nYeeyYsETdW7wAVP5enph0Io4sUF4V9paU+6OH7KRRNrU7vJXTpBd0/eIZkk7 7UOGx+Rc7ISw/1t4agPt5b0lMqINSpXjIGKJ1GvzBBesI2fCfdhHklfhOS6O+DopOBBA AgMg5ivH0UEZhvmj6AOFyTq7+Q98IlHMIp8NU4F7coFJqobxWTBVS4j9w90JkTMn72p5 s2qA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=iPPdxdNjH+Z3WqlsbfrTAMSAeQF9hLdjtDeUbguiUIk=; b=Sh0TtkaMroqeheSPB+wrHfkNcNxdF670mYKAore0rt8MOtth+q9qDC2Y+va1OiRigv 1QqbXTcwAzJKqKC/MXg+s/63d0fZBgtDOgpdYhd7iVPwWoAz5lywWaaez8j/sUdTLnQ+ zUEArbyZpDo6Zpqu+rUAHMq2zAOmwPFlBnu9vgSEY1Mft0Flufem0WvhhL38A6WX8BGw MN/4GbSm0afNEfw4XIxCZw5riNXPHYlaGDkYcefNpZ83uL9Ythk10QC7weDSlMGwPBKR 4unIk7llK/wgbppEN1YNBdG3AE1qiWMFp6kL7DZf/mxF+xv/p1XohJGEJClfcV5+knc+ Oc2A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=r+99ikYB; 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=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id d30si6391319edb.403.2019.11.16.08.20.21; Sat, 16 Nov 2019 08:20:46 -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=@kernel.org header.s=default header.b=r+99ikYB; 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=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730537AbfKPQP7 (ORCPT + 99 others); Sat, 16 Nov 2019 11:15:59 -0500 Received: from mail.kernel.org ([198.145.29.99]:53758 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729635AbfKPPrI (ORCPT ); Sat, 16 Nov 2019 10:47:08 -0500 Received: from sasha-vm.mshome.net (unknown [50.234.116.4]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id DD3072083E; Sat, 16 Nov 2019 15:47:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1573919228; bh=PV75VkIsQLSgJfMJKGoDxgGY1yV4axR33hw/nS5ls3w=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=r+99ikYBG5FC64ak8lYuHubAWuli8KXEGLoHwOHONxLvx6m6QjkF+PzGuVutGKO0M 2Gc3CPC6gt7drOKg3hHrhHg8Aeiare6n+EmxD51zAMObRAxh6L0vTeUsFalGMeWwUt 6TkbyiWAnr7bmLU8/FcmIkrmdEylJxNvfuFVm2MY= From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Igor Konopko , Keith Busch , Christoph Hellwig , Sasha Levin , linux-nvme@lists.infradead.org Subject: [PATCH AUTOSEL 4.19 232/237] nvme-pci: fix surprise removal Date: Sat, 16 Nov 2019 10:41:07 -0500 Message-Id: <20191116154113.7417-232-sashal@kernel.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20191116154113.7417-1-sashal@kernel.org> References: <20191116154113.7417-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Igor Konopko [ Upstream commit 751a0cc0cd3a0d51e6aaf6fd3b8bd31f4ecfaf3e ] When a PCIe NVMe device is not present, nvme_dev_remove_admin() calls blk_cleanup_queue() on the admin queue, which frees the hctx for that queue. Moments later, on the same path nvme_kill_queues() calls blk_mq_unquiesce_queue() on admin queue and tries to access hctx of it, which leads to following OOPS: Oops: 0000 [#1] SMP PTI RIP: 0010:sbitmap_any_bit_set+0xb/0x40 Call Trace: blk_mq_run_hw_queue+0xd5/0x150 blk_mq_run_hw_queues+0x3a/0x50 nvme_kill_queues+0x26/0x50 nvme_remove_namespaces+0xb2/0xc0 nvme_remove+0x60/0x140 pci_device_remove+0x3b/0xb0 Fixes: cb4bfda62afa2 ("nvme-pci: fix hot removal during error handling") Signed-off-by: Igor Konopko Reviewed-by: Keith Busch Signed-off-by: Christoph Hellwig Signed-off-by: Sasha Levin --- drivers/nvme/host/core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c index 5d0f99bcc987f..44da9fe5b27b8 100644 --- a/drivers/nvme/host/core.c +++ b/drivers/nvme/host/core.c @@ -3647,7 +3647,7 @@ void nvme_kill_queues(struct nvme_ctrl *ctrl) down_read(&ctrl->namespaces_rwsem); /* Forcibly unquiesce queues to avoid blocking dispatch */ - if (ctrl->admin_q) + if (ctrl->admin_q && !blk_queue_dying(ctrl->admin_q)) blk_mq_unquiesce_queue(ctrl->admin_q); list_for_each_entry(ns, &ctrl->namespaces, list) -- 2.20.1