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