Received: by 2002:a25:7ec1:0:0:0:0:0 with SMTP id z184csp6014503ybc; Wed, 27 Nov 2019 13:25:12 -0800 (PST) X-Google-Smtp-Source: APXvYqyh71FUMmWU+jk/qPCsYglaf7EbfsJIA82u2asiJmdGvZIysk9kZu6UW9VMackR18g4dUlU X-Received: by 2002:a17:906:e087:: with SMTP id gh7mr51153454ejb.278.1574889911926; Wed, 27 Nov 2019 13:25:11 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1574889911; cv=none; d=google.com; s=arc-20160816; b=o3b+06eA017TsBr6ml8QD896NQW9nBWd4ODrx5zJcj1JOwoQRHRpG8F+uWy3NXGs5p gHhYeenVRBPKzrDY2dGD/vUqoG+t3Y36cxefc/yQ1aLfqGU/4HQuWEEpWEFlBOfl3ibP LJoOCi1CpGDV1F+IvGVA5bxDtzZVSssOs0lciKzwUEDfmwG8X3lzjsUHLDBDwAZwb68e e+diATWKuicS2PGZ6w4qF0VfeZDSpbybtPg0/gR6lGQDYrLVUSYyECQemC5u1H3tb6ql 2m7Lh9dvbd6MoZewp1Kd0O5oVziW/QZmqdm4mkNM4ZLCmnHN/1onHNOda8b/O1Tk2rCn XeAA== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=iPPdxdNjH+Z3WqlsbfrTAMSAeQF9hLdjtDeUbguiUIk=; b=Gw/H+R7XTG4NBBKGDdwZ5UGXn3cuG6Hq15/rQKNpXl86V7HgimMt7NhzkTeXhPybK2 /vPzNGi8j64HU0W8wfQBb7ePs3F1lkpLeto4AXJXUaIq4sea9LJ34DV4bx0NDPwa1o6X BPAkOiuVLE+0Zb8JfVGibpZ/Gox/A134C5xVoNHslA7eW465POAbuaYUzVvRzQWOJtrq Hia8dzUEaL/l9F43nPEWAeaWTC7aIl7azd9ngaJL9pl5+xT4lJe2XIKFFfNi4/ih0VKD cym9QalGhhv4Q5bifu3Y78lLqnSDlXhsFosQLeLLzK1OSLjr2QoKe19W8m33Pz/acW/x y4Og== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=gi5RZJsA; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id x4si10312381ejs.376.2019.11.27.13.24.48; Wed, 27 Nov 2019 13:25:11 -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=gi5RZJsA; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732244AbfK0VWl (ORCPT + 99 others); Wed, 27 Nov 2019 16:22:41 -0500 Received: from mail.kernel.org ([198.145.29.99]:59332 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727459AbfK0VFd (ORCPT ); Wed, 27 Nov 2019 16:05:33 -0500 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 3E19B2080F; Wed, 27 Nov 2019 21:05:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1574888732; bh=PV75VkIsQLSgJfMJKGoDxgGY1yV4axR33hw/nS5ls3w=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=gi5RZJsAhPF4iz/AVgy3HeWZZRmedDCvY1UFGbZpRYu/l2oyDlDwc5qTOzgsgTpSQ k0N9LgXmqoy7wXqjJCZXIi6QopEQ4VcwwjOASWmBCwZUpcH+cp7Odx6m6CNzz6SsWc RUvlD2kcc5nsG4Gzu2Eq7kty2L34BkJwwNqVHcoA= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Igor Konopko , Keith Busch , Christoph Hellwig , Sasha Levin Subject: [PATCH 4.19 249/306] nvme-pci: fix surprise removal Date: Wed, 27 Nov 2019 21:31:39 +0100 Message-Id: <20191127203133.104515360@linuxfoundation.org> X-Mailer: git-send-email 2.24.0 In-Reply-To: <20191127203114.766709977@linuxfoundation.org> References: <20191127203114.766709977@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 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