From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-20.2 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id A454EC433F5 for ; Mon, 20 Sep 2021 16:56:47 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 8254761356 for ; Mon, 20 Sep 2021 16:56:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S245484AbhITQ6M (ORCPT ); Mon, 20 Sep 2021 12:58:12 -0400 Received: from mail.kernel.org ([198.145.29.99]:39212 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1343557AbhITQyp (ORCPT ); Mon, 20 Sep 2021 12:54:45 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 7A1F76138F; Mon, 20 Sep 2021 16:50:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1632156649; bh=X73W8+lecl+2gQJjUWNNpqFRg2L8jX9VBx6ncKnREhg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=cYjPAFKVL+c/SQ3Glr8cuCMs2LTkiTh9hW6I2OYzE7JT/hhaEmi49vNo1Pe96dc9c SIYE4fE0m74A/4yPMDNhdbjvYqVJ7Gc9Sw2KvDlq1Ek/vXty0cFLIRWzWcX7csTRBv UKBLULpswROmKZ1GsC0EbbOledtTE/8uEsRS0x9k= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Christophe JAILLET , Keith Busch , Christoph Hellwig , Jens Axboe Subject: [PATCH 4.9 022/175] nvme-pci: Fix an error handling path in nvme_probe() Date: Mon, 20 Sep 2021 18:41:11 +0200 Message-Id: <20210920163918.799178405@linuxfoundation.org> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20210920163918.068823680@linuxfoundation.org> References: <20210920163918.068823680@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Christophe JAILLET commit b00c9b7aa06786fc5469783965ff3e2a705a1dec upstream. Release resources in the correct order in order not to miss a 'put_device()' if 'nvme_dev_map()' fails. Fixes: b00a726a9fd8 ("NVMe: Don't unmap controller registers on reset") Signed-off-by: Christophe JAILLET Reviewed-by: Keith Busch Signed-off-by: Christoph Hellwig Signed-off-by: Jens Axboe Signed-off-by: Greg Kroah-Hartman --- drivers/nvme/host/pci.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) --- a/drivers/nvme/host/pci.c +++ b/drivers/nvme/host/pci.c @@ -1927,7 +1927,7 @@ static int nvme_probe(struct pci_dev *pd result = nvme_dev_map(dev); if (result) - goto free; + goto put_pci; INIT_WORK(&dev->reset_work, nvme_reset_work); INIT_WORK(&dev->remove_work, nvme_remove_dead_ctrl_work); @@ -1938,7 +1938,7 @@ static int nvme_probe(struct pci_dev *pd result = nvme_setup_prp_pools(dev); if (result) - goto put_pci; + goto unmap; result = nvme_init_ctrl(&dev->ctrl, &pdev->dev, &nvme_pci_ctrl_ops, id->driver_data); @@ -1953,9 +1953,10 @@ static int nvme_probe(struct pci_dev *pd release_pools: nvme_release_prp_pools(dev); + unmap: + nvme_dev_unmap(dev); put_pci: put_device(dev->dev); - nvme_dev_unmap(dev); free: kfree(dev->queues); kfree(dev);