All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] bus: mhi: ep: Fix signedness bug in mhi_ep_register_controller()
@ 2022-03-07 14:28 Dan Carpenter
  2022-03-07 14:50 ` Alex Elder
  2022-03-07 15:09 ` Manivannan Sadhasivam
  0 siblings, 2 replies; 4+ messages in thread
From: Dan Carpenter @ 2022-03-07 14:28 UTC (permalink / raw)
  To: Manivannan Sadhasivam
  Cc: Hemant Kumar, Alex Elder, mhi, linux-arm-msm, kernel-janitors

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


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

* Re: [PATCH] bus: mhi: ep: Fix signedness bug in mhi_ep_register_controller()
  2022-03-07 14:28 [PATCH] bus: mhi: ep: Fix signedness bug in mhi_ep_register_controller() Dan Carpenter
@ 2022-03-07 14:50 ` Alex Elder
  2022-03-07 14:53   ` Dan Carpenter
  2022-03-07 15:09 ` Manivannan Sadhasivam
  1 sibling, 1 reply; 4+ messages in thread
From: Alex Elder @ 2022-03-07 14:50 UTC (permalink / raw)
  To: Dan Carpenter, Manivannan Sadhasivam
  Cc: Hemant Kumar, mhi, linux-arm-msm, kernel-janitors

On 3/7/22 8:28 AM, Dan Carpenter wrote:
> 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>

Good fix.  Is this code upstream somewhere?

Reviewed-by: Alex Elder <elder@linaro.org>

> ---
>   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,


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

* Re: [PATCH] bus: mhi: ep: Fix signedness bug in mhi_ep_register_controller()
  2022-03-07 14:50 ` Alex Elder
@ 2022-03-07 14:53   ` Dan Carpenter
  0 siblings, 0 replies; 4+ messages in thread
From: Dan Carpenter @ 2022-03-07 14:53 UTC (permalink / raw)
  To: Alex Elder
  Cc: Manivannan Sadhasivam, Hemant Kumar, mhi, linux-arm-msm, kernel-janitors

On Mon, Mar 07, 2022 at 08:50:32AM -0600, Alex Elder wrote:
> On 3/7/22 8:28 AM, Dan Carpenter wrote:
> > 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>
> 
> Good fix.  Is this code upstream somewhere?

It's in linux-next.

regards,
dan carpenter


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

* Re: [PATCH] bus: mhi: ep: Fix signedness bug in mhi_ep_register_controller()
  2022-03-07 14:28 [PATCH] bus: mhi: ep: Fix signedness bug in mhi_ep_register_controller() Dan Carpenter
  2022-03-07 14:50 ` Alex Elder
@ 2022-03-07 15:09 ` Manivannan Sadhasivam
  1 sibling, 0 replies; 4+ messages in thread
From: Manivannan Sadhasivam @ 2022-03-07 15:09 UTC (permalink / raw)
  To: Dan Carpenter
  Cc: Hemant Kumar, Alex Elder, mhi, linux-arm-msm, kernel-janitors

On Mon, Mar 07, 2022 at 05:28:22PM +0300, Dan Carpenter wrote:
> 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>

Thanks for the fix! The fix was already added to mhi-next (squashed) as a
response to the previous report.

https://lore.kernel.org/mhi/20220307071739.GM12451@workstation/T/#t

Thanks,
Mani

> ---
>  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
> 

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

end of thread, other threads:[~2022-03-07 15:09 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-03-07 14:28 [PATCH] bus: mhi: ep: Fix signedness bug in mhi_ep_register_controller() Dan Carpenter
2022-03-07 14:50 ` Alex Elder
2022-03-07 14:53   ` Dan Carpenter
2022-03-07 15:09 ` Manivannan Sadhasivam

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.