Skip to content

Commit

Permalink
IB/mthca: fix return value of error branch in mthca_init_cq()
Browse files Browse the repository at this point in the history
[ Upstream commit 6830ff853a5764c75e56750d59d0bbb6b26f1835 ]

We return 'err' in the error branch, but this variable may be set as zero
by the above code. Fix it by setting 'err' as a negative value before we
goto the error label.

Fixes: 74c2174 ("IB uverbs: add mthca user CQ support")
Fixes: 1da177e ("Linux-2.6.12-rc2")
Link: https://lore.kernel.org/r/[email protected]
Reported-by: Hulk Robot <[email protected]>
Signed-off-by: Xiongfeng Wang <[email protected]>
Signed-off-by: Jason Gunthorpe <[email protected]>
Signed-off-by: Sasha Levin <[email protected]>
  • Loading branch information
fenghusthu authored and toraidl committed Mar 28, 2024
1 parent 33aae7d commit ab8f026
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions drivers/infiniband/hw/mthca/mthca_cq.c
Original file line number Diff line number Diff line change
Expand Up @@ -808,8 +808,10 @@ int mthca_init_cq(struct mthca_dev *dev, int nent,
}

mailbox = mthca_alloc_mailbox(dev, GFP_KERNEL);
if (IS_ERR(mailbox))
if (IS_ERR(mailbox)) {
err = PTR_ERR(mailbox);
goto err_out_arm;
}

cq_context = mailbox->buf;

Expand Down Expand Up @@ -851,9 +853,9 @@ int mthca_init_cq(struct mthca_dev *dev, int nent,
}

spin_lock_irq(&dev->cq_table.lock);
if (mthca_array_set(&dev->cq_table.cq,
cq->cqn & (dev->limits.num_cqs - 1),
cq)) {
err = mthca_array_set(&dev->cq_table.cq,
cq->cqn & (dev->limits.num_cqs - 1), cq);
if (err) {
spin_unlock_irq(&dev->cq_table.lock);
goto err_out_free_mr;
}
Expand Down

0 comments on commit ab8f026

Please sign in to comment.