public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Dan Carpenter <dan.carpenter@oracle.com>
To: Alison Schofield <alison.schofield@intel.com>,
	Ben Widawsky <ben.widawsky@intel.com>
Cc: Vishal Verma <vishal.l.verma@intel.com>,
	Ira Weiny <ira.weiny@intel.com>,
	Dan Williams <dan.j.williams@intel.com>,
	linux-cxl@vger.kernel.org, linux-kernel@vger.kernel.org,
	kernel-janitors@vger.kernel.org
Subject: [PATCH] cxl/mem: Fix an error code in cxl_mem_mbox_get()
Date: Tue, 16 Feb 2021 22:16:48 +0300	[thread overview]
Message-ID: <YCwaIGPd9ktMoYPu@mwanda> (raw)

Smatch complains that sometimes when we return success we are holding
the mutex and sometimes we have released the mutex.  It turns out that
the bug is a missing error code if the mbox is not ready.  It should
return -EBUSY instead of success.

Fixes: cc1967ac93ab ("cxl/mem: Find device capabilities")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
---
 drivers/cxl/mem.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/cxl/mem.c b/drivers/cxl/mem.c
index 3bca8451348a..2ebc84e4d202 100644
--- a/drivers/cxl/mem.c
+++ b/drivers/cxl/mem.c
@@ -383,8 +383,8 @@ static int __cxl_mem_mbox_send_cmd(struct cxl_mem *cxlm,
 static int cxl_mem_mbox_get(struct cxl_mem *cxlm)
 {
 	struct device *dev = &cxlm->pdev->dev;
-	int rc = -EBUSY;
 	u64 md_status;
+	int rc;
 
 	mutex_lock_io(&cxlm->mbox_mutex);
 
@@ -414,6 +414,7 @@ static int cxl_mem_mbox_get(struct cxl_mem *cxlm)
 	md_status = readq(cxlm->memdev_regs + CXLMDEV_STATUS_OFFSET);
 	if (!(md_status & CXLMDEV_MBOX_IF_READY && CXLMDEV_READY(md_status))) {
 		dev_err(dev, "mbox: reported doorbell ready, but not mbox ready\n");
+		rc = -EBUSY;
 		goto out;
 	}
 
-- 
2.30.0


             reply	other threads:[~2021-02-16 19:18 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-02-16 19:16 Dan Carpenter [this message]
2021-02-16 20:52 ` [PATCH] cxl/mem: Fix an error code in cxl_mem_mbox_get() Dan Williams

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=YCwaIGPd9ktMoYPu@mwanda \
    --to=dan.carpenter@oracle.com \
    --cc=alison.schofield@intel.com \
    --cc=ben.widawsky@intel.com \
    --cc=dan.j.williams@intel.com \
    --cc=ira.weiny@intel.com \
    --cc=kernel-janitors@vger.kernel.org \
    --cc=linux-cxl@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=vishal.l.verma@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox