linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] cxl/mem: Fix an error code in cxl_mem_mbox_get()
@ 2021-02-16 19:16 Dan Carpenter
  2021-02-16 20:52 ` Dan Williams
  0 siblings, 1 reply; 2+ messages in thread
From: Dan Carpenter @ 2021-02-16 19:16 UTC (permalink / raw)
  To: Alison Schofield, Ben Widawsky
  Cc: Vishal Verma, Ira Weiny, Dan Williams, linux-cxl, linux-kernel,
	kernel-janitors

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


^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2021-02-16 20:53 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-02-16 19:16 [PATCH] cxl/mem: Fix an error code in cxl_mem_mbox_get() Dan Carpenter
2021-02-16 20:52 ` Dan Williams

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).