bus: mhi: ep: Fix signedness bug in mhi_ep_register_controller()
Subsystems (3)
PATCH 1/1 bus: mhi: ep: Fix signedness bug in mhi_ep_register_controller()
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 <[email protected]>
--- drivers/bus/mhi/ep/main.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-)
drivers/bus/mhi/ep/main.c +3 -4
@@ -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,
Signature · 1 line
2.20.1
Quoted 5 lines · Dan Carpenter
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 <[email protected]>
Good fix. Is this code upstream somewhere?
Reviewed-by Alex Elder <[email protected]>
Quoted 23 lines
--- drivers/bus/mhi/ep/main.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-)drivers/bus/mhi/ep/main.c +3
-4@@ -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,
Quoted 8 lines · Alex Elder
Quoted 5 lines · Dan Carpenter
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 <[email protected]>Good fix. Is this code upstream somewhere?
It's in linux-next.
regards,
dan carpenter
Manivannan Sadhasivam
maintainerQuoted 5 lines · Dan Carpenter
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 <[email protected]>
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
Quoted 26 lines
--- drivers/bus/mhi/ep/main.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-)drivers/bus/mhi/ep/main.c +3
-4@@ -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,Signature · 1 line
2.20.1