Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp5441633imm; Tue, 19 Jun 2018 10:24:07 -0700 (PDT) X-Google-Smtp-Source: ADUXVKIpyOUNSmMtCuDUo++lb7ZJwPkdKtHOfCCzN40X5nKCSwETtkBX+bguYROL4uswC+koQrCG X-Received: by 2002:a17:902:8d8b:: with SMTP id v11-v6mr20125840plo.20.1529429047846; Tue, 19 Jun 2018 10:24:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1529429047; cv=none; d=google.com; s=arc-20160816; b=bE06pf7IdpHd+8pnjKPTNJw194Tvmu7C5OmsOZ4ks1p9Hq20DYo+Mr5AlU+5Cs4f79 zdnkqWDAPyBoHUjotWWUlDyQki/kt2kOd0vDzDJdvVwi6kt6hyQZ4372vZMKzMOb8GTC Ncy3GyNjwWTr8XcyoPpYTMXU7ZeHg70XT6OXki1Ygmm8I8rGy4RHG0sy8HTuTP811Wiu tUou9pZBI3QmsOQ4Zkd7VLv+sxRkQ6vG3rOwni58A66IgCh6uAXB3kAYTVPzHGACofFB vRpkoPeTXN/IrC9U7vzZHXmpg/Y4YjN6nF8/ETfI8vfU4GdpFSjbUwj+ZfaDdjx6BDra TCzw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-transfer-encoding:content-disposition:mime-version :message-id:subject:cc:to:from:date:arc-authentication-results; bh=+W2Hz91knAGlbyk0CGMKWM0NeUFrG8YiyUdJb6if9zY=; b=JZBXqUMQCISjdKiBMCjn9ndPK6un0bk3cXFf823q+zQ7LN5syslTdI1K0RbKErsELw EyCBhBMoReg2LbP4/QVCEAN9MYz1/p5JOhjZvmIot9YUlhepq+pUoIPxOP2eakxT4M0c L8OrnEYRGF8HFOmAOAS1KlL/mlz6lBQ/WTfYj8Sf8yqu0QOHnjl7x/zJZ4cLkXnjoaMw tgrmwug7YRCiPchuD5a9ZFtB/FSRvvUzHwVCLa1vCOIMIY3B1IMNbI+iZ0S64+RndkOA ATIHlfw70UmWOBja10NU/gbCVtXRhVerl9rrPlMgmw91ZG43B8DTZ0JHJDS1Iwentk8j NZxg== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=codethink.co.uk Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id p22-v6si142201plo.141.2018.06.19.10.23.53; Tue, 19 Jun 2018 10:24:07 -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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=codethink.co.uk Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S967019AbeFSRXP convert rfc822-to-8bit (ORCPT + 99 others); Tue, 19 Jun 2018 13:23:15 -0400 Received: from imap1.codethink.co.uk ([176.9.8.82]:60858 "EHLO imap1.codethink.co.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S966551AbeFSRXN (ORCPT ); Tue, 19 Jun 2018 13:23:13 -0400 Received: from [148.252.241.226] (helo=xylophone.i.decadent.org.uk) by imap1.codethink.co.uk with esmtpsa (Exim 4.84_2 #1 (Debian)) id 1fVKLT-0007JZ-SQ; Tue, 19 Jun 2018 18:23:08 +0100 Date: Tue, 19 Jun 2018 18:23:06 +0100 From: Ben Hutchings To: Greg Kroah-Hartman Cc: Keith Busch , Jianchao Wang , stable@vger.kernel.org, Sasha Levin , linux-kernel@vger.kernel.org Subject: [PATCH 4.4] nvme-pci: initialize queue memory before interrupts Message-ID: <20180619172306.atcqdzb2tdk3ivvt@xylophone.i.decadent.org.uk> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: 8BIT In-Reply-To: <20180613171320.GB28828@kroah.com> User-Agent: NeoMutt/20170113 (1.7.2) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Keith Busch commit 161b8be2bd6abad250d4b3f674bdd5480f15beeb upstream. A spurious interrupt before the nvme driver has initialized the completion queue may inadvertently cause the driver to believe it has a completion to process. This may result in a NULL dereference since the nvmeq's tags are not set at this point. The patch initializes the host's CQ memory so that a spurious interrupt isn't mistaken for a real completion. Signed-off-by: Keith Busch Reviewed-by: Johannes Thumshirn Signed-off-by: Christoph Hellwig [bwh: Backported to 4.4: adjust context] Signed-off-by: Jens Axboe --- drivers/nvme/host/pci.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/nvme/host/pci.c b/drivers/nvme/host/pci.c index e86fcc9e9852..01f47b68b6e7 100644 --- a/drivers/nvme/host/pci.c +++ b/drivers/nvme/host/pci.c @@ -1589,11 +1589,11 @@ static int nvme_create_queue(struct nvme_queue *nvmeq, int qid) if (result < 0) goto release_cq; + nvme_init_queue(nvmeq, qid); result = queue_request_irq(dev, nvmeq, nvmeq->irqname); if (result < 0) goto release_sq; - nvme_init_queue(nvmeq, qid); return result; release_sq: @@ -1797,6 +1797,7 @@ static int nvme_configure_admin_queue(struct nvme_dev *dev) goto free_nvmeq; nvmeq->cq_vector = 0; + nvme_init_queue(nvmeq, 0); result = queue_request_irq(dev, nvmeq, nvmeq->irqname); if (result) { nvmeq->cq_vector = -1; @@ -3165,7 +3166,6 @@ static void nvme_probe_work(struct work_struct *work) goto disable; } - nvme_init_queue(dev->queues[0], 0); result = nvme_alloc_admin_tags(dev); if (result) goto disable; -- Ben Hutchings, Software Developer Codethink Ltd https://www.codethink.co.uk/ Dale House, 35 Dale Street Manchester, M1 2HF, United Kingdom