Received: by 2002:a25:c593:0:0:0:0:0 with SMTP id v141csp1019860ybe; Wed, 4 Sep 2019 11:14:28 -0700 (PDT) X-Google-Smtp-Source: APXvYqyknJuftxL3YQf3UFe9gZWNNuNrqp4dn+jGwiD7MxAticCD+b34Gu8pB4Fzfj07NPJcF5MI X-Received: by 2002:aa7:99da:: with SMTP id v26mr5658955pfi.258.1567620868846; Wed, 04 Sep 2019 11:14:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1567620868; cv=none; d=google.com; s=arc-20160816; b=JgVI9sEJuxDgLeNp+x+8OBOGx0zDeicMXnBc76k5ok+zw/3Nxep9LgZyLvxgGRNUPp Acu6M172sZT/43zZGAV6FpmMS0NFHQ5q4CO7OXcoocXuMKKby14fx/xxrKMYDCvD/GnH OsACrTLEpHGSZehg9V5rzZmFPtEqOKtjafX8FkTzvL6XFY8JPtAMElM/7jKBKmdGG2iU 7dR9T1n8eYdBhP17UvkPZGKmcmK3EpXCkdW+PQ+ktmSAup9XNUR1O1pfCDOz/soViBvd n3cNQb16MhjtichdLFkW01uRBogHqFa84xfWBU11cBTdJtVc4qE3Ii167EZx7rizlwYd PeaQ== 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=TadPsLZDa8DtbQVXCsJkYj6O8MXJG9qUP+8ttNn4/fw=; b=ZZCN+AEzIE9KG/po+NKllbR+t/LFAc9vBxHHT8WYCzCIhidaKeBd4BOOMH24LHLrNR DG+1LjWQPfpgVvfCIr7m39u7hP8H3lHfcxDG3Qw21rvXBErHJPDPxP9Kp8OyPU66/dnY Qhc+IEXQZKuzaZGkRJBlOgDvMEugGzWRyDFCi83kcOY/D8kzhVVSmR83CmsO7RNATuLO d7kPMUSjFxH3jfAUtJLYoBmbIlTyksGgFDFhPgsz1tuG67ZbrMLqST3Xt/A4mHATqX76 hjk24AajQMU8WJo0sUVVYXcQeh7iMnVyKoJZcLW+NyfgVnKujp9ktn0KUNK0oUAmUgKP OJkg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=DusmTX5h; 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 u14si10568861pfc.222.2019.09.04.11.14.11; Wed, 04 Sep 2019 11:14:28 -0700 (PDT) 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=DusmTX5h; 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 S2390392AbfIDSLb (ORCPT + 99 others); Wed, 4 Sep 2019 14:11:31 -0400 Received: from mail.kernel.org ([198.145.29.99]:55480 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2390335AbfIDSL1 (ORCPT ); Wed, 4 Sep 2019 14:11:27 -0400 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 DBC9D2087E; Wed, 4 Sep 2019 18:11:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1567620686; bh=MQiAGOW7PCLLPupgghlunayvmyad+OpM+CldYOEc8ps=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=DusmTX5hTrqA/OEv+vOwYeT/Ck8nMkc72Bpa6hr53JZmxffbsWizVu39atoxCPj+i FgO2qcYsTyx9dfZu3RWu4GqFR/L1g4qAaNWrlKTKOGGaGPZS3DXIkuYsITtKK4gmZK IltD3aLz8QaOv32Y0k7RHP45KLnfjEYfJtcE+pe0= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Li Zhong , Sagi Grimberg , Keith Busch , Sasha Levin Subject: [PATCH 5.2 016/143] nvme-pci: Fix async probe remove race Date: Wed, 4 Sep 2019 19:52:39 +0200 Message-Id: <20190904175314.720373935@linuxfoundation.org> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20190904175314.206239922@linuxfoundation.org> References: <20190904175314.206239922@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 [ Upstream commit bd46a90634302bfe791e93ad5496f98f165f7ae0 ] Ensure the controller is not in the NEW state when nvme_probe() exits. This will always allow a subsequent nvme_remove() to set the state to DELETING, fixing a potential race between the initial asynchronous probe and device removal. Reported-by: Li Zhong Reviewed-by: Sagi Grimberg Signed-off-by: Keith Busch Signed-off-by: Sagi Grimberg Signed-off-by: Sasha Levin --- drivers/nvme/host/pci.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/nvme/host/pci.c b/drivers/nvme/host/pci.c index f9959eaaa185e..09ffd21d18096 100644 --- a/drivers/nvme/host/pci.c +++ b/drivers/nvme/host/pci.c @@ -2712,7 +2712,7 @@ static void nvme_async_probe(void *data, async_cookie_t cookie) { struct nvme_dev *dev = data; - nvme_reset_ctrl_sync(&dev->ctrl); + flush_work(&dev->ctrl.reset_work); flush_work(&dev->ctrl.scan_work); nvme_put_ctrl(&dev->ctrl); } @@ -2778,6 +2778,7 @@ static int nvme_probe(struct pci_dev *pdev, const struct pci_device_id *id) dev_info(dev->ctrl.device, "pci function %s\n", dev_name(&pdev->dev)); + nvme_reset_ctrl(&dev->ctrl); nvme_get_ctrl(&dev->ctrl); async_schedule(nvme_async_probe, dev); -- 2.20.1