Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp9929424ybi; Wed, 24 Jul 2019 12:30:55 -0700 (PDT) X-Google-Smtp-Source: APXvYqzGdcQcnhl9fg4prrecdNVzELxigf7S1xfKLMb1Uin++BJT6KJCIwEirnZK9VDztb+cUKvz X-Received: by 2002:a65:64c4:: with SMTP id t4mr46539438pgv.298.1563996655075; Wed, 24 Jul 2019 12:30:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1563996655; cv=none; d=google.com; s=arc-20160816; b=AU7g29fxCBwVz3RhQjKiPI0m0eG0sPGejDskmhNThql4OEp7HGNWUr6pLn5gIaFeKf QCtKijQN/cZcWDar8iA5HIi/BEWfuDlJAOhXIJQEdmHlW9rCFcmkPKbQ2ihnf36Lj0fR rE457ppAxxC54A71DYvgRHM3ypR5M/aMG+Iur1kSMV9Ihqjlgdqo5YFgxbZEPchuyAxu W0hU699Tr5QuGnlQC40FfC/m0KpB60lY2jtUyKbUlsuJjZC5I0hPWC64f5AWtzCma5Rm D80lVZUCfqWsJ97FiArMO2SIioSJlCv5t/8zux7ZIf+NqMXbHnP2UgsdgHv4TmWTMCOA P9/A== 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=qRsZC9RybU0622fy5ZY2TwVKwbf4WChbHFFYjT6BaEE=; b=t7fJcTmEV9fipL0to6ogWmm4fzvp5BxiHmrOJPDIupFIV9Y3sA7ujnE2nMn/M1Q6jS JCioeIZcG8OXYt0H5l4ol+Ew5wJjhwmvkDzU623vIPOSvQKSJAklLp7H4QLcyVx+KwLf v+DO4DJnatss9FTQwjRlpZ3uzlIzq0fKmeGz6Kug7j9Hcjk+T4rcgjaL5cx/sQOkVFxn CKtFyHX881Wf2q0o/JdOnJtJ3LblSEnRhHfqDxY8LcAMVO3YeiweqBch01GnEJrM89/L zqCWSsQGzKp3Fgs+PtkyAP+p/txZZwJV6RYi4H6nzQMbhW+Og/5Tck+HG6I7GMUOQ6Gu bi+Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=YuePSJNU; 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 j8si14920092plt.303.2019.07.24.12.30.40; Wed, 24 Jul 2019 12:30:55 -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=YuePSJNU; 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 S1729310AbfGXT3B (ORCPT + 99 others); Wed, 24 Jul 2019 15:29:01 -0400 Received: from mail.kernel.org ([198.145.29.99]:47804 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729072AbfGXT3A (ORCPT ); Wed, 24 Jul 2019 15:29:00 -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 413FD22ADB; Wed, 24 Jul 2019 19:28:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1563996539; bh=n+KGSrXWUISdL/JRNN9XQlyEeqoBeEVYJjtR3aFNUcA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=YuePSJNUtTHiqhQuF83koAKUzUR1drMqB45Yx2R5pogPDx0/zqv7WOyvy0uoX2gBS BeyHb7aDoV2rxuGNEO2T44a9a/ONvn7tTYDi87yawaWlTtZRxRQf52Kl9WXVFJZV74 CwBFjwrQm6Oal4UFypELxDSHAlht2U66cAmMtfQI= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Chaitanya Kulkarni , Christoph Hellwig , Sasha Levin Subject: [PATCH 5.2 133/413] nvme-pci: set the errno on ctrl state change error Date: Wed, 24 Jul 2019 21:17:04 +0200 Message-Id: <20190724191744.540068803@linuxfoundation.org> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190724191735.096702571@linuxfoundation.org> References: <20190724191735.096702571@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 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 385ba7a1e23b..544d095d44e5 100644 --- a/drivers/nvme/host/pci.c +++ b/drivers/nvme/host/pci.c @@ -2480,11 +2480,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 @@ -2589,6 +2591,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