Received: by 2002:a25:c593:0:0:0:0:0 with SMTP id v141csp1019973ybe; Wed, 4 Sep 2019 11:14:33 -0700 (PDT) X-Google-Smtp-Source: APXvYqxYiqFca/rFzKC0vLCJvQ5cJt6lvHjimWjbio3l4ORyuN4zRe5UNOrxbppuxVhdvS0CnJU1 X-Received: by 2002:a62:28c:: with SMTP id 134mr48621210pfc.194.1567620873795; Wed, 04 Sep 2019 11:14:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1567620873; cv=none; d=google.com; s=arc-20160816; b=UPXtG3k+js6xUrEPAX1uRGYrSAgdXwMmoSyopjFhWckeydlb3Q8vAsDrwtht6XrYvY AzGa3lFG3xghoX0zdJB3WTK3Z0L3rYbAvsJGvpBNGpHrBypPWSTbGQPRTCd7RZAlqByK w23POGg9iorXgoUtX3VNULIusigznFqPt9ZVUoLcmvrhuVnqrLdWByh6nZ8HoEKLmYaz TTu6/pP0ruOoygC29gPDEDfbFyZFDwKPyh5XUafEw3hrCMU3RtSok6b8Iii+jOcMCcqp dw/9sh+rAr/ZxYuD+TMX8pnnzmT0RkGnrIf2c08gh50xjIsX4jFxQkrYDLGtJgDculPH AXxQ== 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=cSUJCaQqWXWpjsihpt0zG5ZCefCuLoJh6UPa34HYu20=; b=ZZaYBH6tzb2EPGZaox+Lj6CHrioM26Hye5FwU7dR4uANDhMNBDEdbIdWWnI+cDb9B6 +m2nHlc2r50qKPg8qeTLUEcRHm9MU+0jbvveTFWpmmw3XXOiCPPsJ4u8uCrNpTmO/ZA/ eNDiUX1PktYwIsXzl84pv50JL9FaZJYnngIrhf8We8uMz2ktmYFW1z2GmYTuNwx7pDk7 NSKT6CGkU3zrphvWGCv4qyHkLaRDoB4oc6IoQ91L7NSEwPhf8/K5iSk7+Nl0TGZU24zp /lHEXspoS53TJd2fQ8PBv9Tso7QzEyXyTE9P2mbTTXNZ+qm8/Ig3x+BlUMxKCbHifJT3 N/Sg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=kljMIKQi; 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 x130si17774740pgx.526.2019.09.04.11.14.18; Wed, 04 Sep 2019 11:14:33 -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=kljMIKQi; 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 S1732901AbfIDSLn (ORCPT + 99 others); Wed, 4 Sep 2019 14:11:43 -0400 Received: from mail.kernel.org ([198.145.29.99]:55772 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388806AbfIDSLk (ORCPT ); Wed, 4 Sep 2019 14:11:40 -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 31163206B8; Wed, 4 Sep 2019 18:11:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1567620699; bh=ScpewfHPSZ83E08AM4jG+abwOpaZQZLHQlnlmK+lkto=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=kljMIKQi0HP4IJxYjAOrCPnqEJWXME/PG+CgvruqbYIXxZik19vK6rP2AzK5P5Ifx mW34IVvvSgwn5MLu9IZFuJl3QyDhBvSp01yeTRR3zCJDFDGH2cwhlb9R41AMeKoFkb ijDiB7OLUvz8gbNEcTlNp6LSu0r3oikDdsPVI+ag= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Logan Gunthorpe , Sagi Grimberg , Chaitanya Kulkarni , Sasha Levin Subject: [PATCH 5.2 011/143] nvmet-file: fix nvmet_file_flush() always returning an error Date: Wed, 4 Sep 2019 19:52:34 +0200 Message-Id: <20190904175314.554285195@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 cfc1a1af56200362d1508b82b9a3cc3acb2eae0c ] Presently, nvmet_file_flush() always returns a call to errno_to_nvme_status() but that helper doesn't take into account the case when errno=0. So nvmet_file_flush() always returns an error code. All other callers of errno_to_nvme_status() check for success before calling it. To fix this, ensure errno_to_nvme_status() returns success if the errno is zero. This should prevent future mistakes like this from happening. Fixes: c6aa3542e010 ("nvmet: add error log support for file backend") Signed-off-by: Logan Gunthorpe Reviewed-by: Sagi Grimberg Reviewed-by: Chaitanya Kulkarni Signed-off-by: Sagi Grimberg Signed-off-by: Sasha Levin --- drivers/nvme/target/core.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/nvme/target/core.c b/drivers/nvme/target/core.c index e4db9a4411681..396cbc7ea3532 100644 --- a/drivers/nvme/target/core.c +++ b/drivers/nvme/target/core.c @@ -43,6 +43,9 @@ inline u16 errno_to_nvme_status(struct nvmet_req *req, int errno) u16 status; switch (errno) { + case 0: + status = NVME_SC_SUCCESS; + break; case -ENOSPC: req->error_loc = offsetof(struct nvme_rw_command, length); status = NVME_SC_CAP_EXCEEDED | NVME_SC_DNR; -- 2.20.1