Linux MHI Development
 help / color / mirror / Atom feed
From: Dan Carpenter <dan.carpenter@oracle.com>
To: Manivannan Sadhasivam <mani@kernel.org>
Cc: Hemant Kumar <hemantk@codeaurora.org>,
	Alex Elder <elder@linaro.org>,
	mhi@lists.linux.dev, linux-arm-msm@vger.kernel.org,
	kernel-janitors@vger.kernel.org
Subject: [PATCH] bus: mhi: ep: Fix signedness bug in mhi_ep_register_controller()
Date: Mon, 7 Mar 2022 17:28:22 +0300	[thread overview]
Message-ID: <20220307142822.GC19660@kili> (raw)

The "mhi_cntrl->index" variable is unsigned so the error handling will
not work.

Fixes: 10f0ab9c6787 ("bus: mhi: ep: Add support for registering MHI endpoint controllers")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
---
 drivers/bus/mhi/ep/main.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/drivers/bus/mhi/ep/main.c b/drivers/bus/mhi/ep/main.c
index 3e98107f08c4..879071b021d5 100644
--- a/drivers/bus/mhi/ep/main.c
+++ b/drivers/bus/mhi/ep/main.c
@@ -1418,11 +1418,10 @@ int mhi_ep_register_controller(struct mhi_ep_cntrl *mhi_cntrl,
 	mhi_ep_mmio_set_env(mhi_cntrl, MHI_EE_AMSS);
 
 	/* Set controller index */
-	mhi_cntrl->index = ida_alloc(&mhi_ep_cntrl_ida, GFP_KERNEL);
-	if (mhi_cntrl->index < 0) {
-		ret = mhi_cntrl->index;
+	ret = ida_alloc(&mhi_ep_cntrl_ida, GFP_KERNEL);
+	if (ret < 0)
 		goto err_destroy_wq;
-	}
+	mhi_cntrl->index = ret;
 
 	irq_set_status_flags(mhi_cntrl->irq, IRQ_NOAUTOEN);
 	ret = request_irq(mhi_cntrl->irq, mhi_ep_irq, IRQF_TRIGGER_HIGH,
-- 
2.20.1


             reply	other threads:[~2022-03-07 14:28 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-03-07 14:28 Dan Carpenter [this message]
2022-03-07 14:50 ` [PATCH] bus: mhi: ep: Fix signedness bug in mhi_ep_register_controller() Alex Elder
2022-03-07 14:53   ` Dan Carpenter
2022-03-07 15:09 ` Manivannan Sadhasivam

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=20220307142822.GC19660@kili \
    --to=dan.carpenter@oracle.com \
    --cc=elder@linaro.org \
    --cc=hemantk@codeaurora.org \
    --cc=kernel-janitors@vger.kernel.org \
    --cc=linux-arm-msm@vger.kernel.org \
    --cc=mani@kernel.org \
    --cc=mhi@lists.linux.dev \
    /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