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=-10.1 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham 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 252F8C76191 for ; Mon, 15 Jul 2019 14:23:20 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id E92592053B for ; Mon, 15 Jul 2019 14:23:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1563200600; bh=w02hCbkEW8H4mxyePHmWDo6/6g+lVjws7tYYS8cVE7o=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=m16QPMPUXWBorATrhBr8U+jD1ZnyjmtPNlIjSYJxCFo48lIg3iUi9ILAMYOyfLYa3 4ZlOGqCugmXSL5FAOSCl8Y9oMkDz5X+8+HKwQnAwtXAvsmBrYIxS4MiI+8tuW6OrT4 aFnlDE0XPUz9BusW7sIUEAL7jDoQjIbVrvPGgwsw= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2390735AbfGOOXS (ORCPT ); Mon, 15 Jul 2019 10:23:18 -0400 Received: from mail.kernel.org ([198.145.29.99]:54014 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2390725AbfGOOXP (ORCPT ); Mon, 15 Jul 2019 10:23:15 -0400 Received: from sasha-vm.mshome.net (unknown [73.61.17.35]) (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 34BD921849; Mon, 15 Jul 2019 14:23:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1563200595; bh=w02hCbkEW8H4mxyePHmWDo6/6g+lVjws7tYYS8cVE7o=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=uIYNUZw6VI8DaLKLQ0vPNlfQ4/QKKY1ld6m1MyuDPbSHhp8JtvBp+ZHiddgnAdmkx Y9Af5jKaIodOnWt8odBAHpp7p8Ig+G2OLwsKXVm+UAxszF6i9kc1r+9jWmWDt6zaph kXwa4a4FBFZS0LqBq6ns/2Jiyx4cE+FgtiHdo0oU= From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Chaitanya Kulkarni , Christoph Hellwig , Sasha Levin , linux-nvme@lists.infradead.org Subject: [PATCH AUTOSEL 4.19 087/158] nvme-pci: set the errno on ctrl state change error Date: Mon, 15 Jul 2019 10:16:58 -0400 Message-Id: <20190715141809.8445-87-sashal@kernel.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190715141809.8445-1-sashal@kernel.org> References: <20190715141809.8445-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: Chaitanya Kulkarni [ Upstream commit e71afda49335620e3d9adf56015676db33a3bd86 ] This patch removes the confusing assignment of the variable result at the time of declaration and sets the value in error cases next to the places where the actual error is happening. Here we also set the result value to -ENODEV when we fail at the final ctrl state transition in nvme_reset_work(). Without this assignment result will hold 0 from nvme_setup_io_queue() and on failure 0 will be passed to he nvme_remove_dead_ctrl() from final state transition. Signed-off-by: Chaitanya Kulkarni Signed-off-by: Christoph Hellwig Signed-off-by: Sasha Levin --- drivers/nvme/host/pci.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/drivers/nvme/host/pci.c b/drivers/nvme/host/pci.c index 03e72e2f57f5..0a5d064f82ca 100644 --- a/drivers/nvme/host/pci.c +++ b/drivers/nvme/host/pci.c @@ -2253,11 +2253,13 @@ static void nvme_reset_work(struct work_struct *work) struct nvme_dev *dev = container_of(work, struct nvme_dev, ctrl.reset_work); bool was_suspend = !!(dev->ctrl.ctrl_config & NVME_CC_SHN_NORMAL); - int result = -ENODEV; + int result; enum nvme_ctrl_state new_state = NVME_CTRL_LIVE; - if (WARN_ON(dev->ctrl.state != NVME_CTRL_RESETTING)) + if (WARN_ON(dev->ctrl.state != NVME_CTRL_RESETTING)) { + result = -ENODEV; goto out; + } /* * If we're called to reset a live controller first shut it down before @@ -2355,6 +2357,7 @@ static void nvme_reset_work(struct work_struct *work) if (!nvme_change_ctrl_state(&dev->ctrl, new_state)) { dev_warn(dev->ctrl.device, "failed to mark controller state %d\n", new_state); + result = -ENODEV; goto out; } -- 2.20.1