Skip to content

Commit 6830ff8

Browse files
fenghusthujgunthorpe
authored andcommitted
IB/mthca: fix return value of error branch in mthca_init_cq()
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: 1da177e4c3f4 ("Linux-2.6.12-rc2") Link: https://lore.kernel.org/r/1605837422-42724-1-git-send-email-wangxiongfeng2@huawei.com Reported-by: Hulk Robot <hulkci@huawei.com> Signed-off-by: Xiongfeng Wang <wangxiongfeng2@huawei.com> Signed-off-by: Jason Gunthorpe <jgg@nvidia.com>
1 parent 418baf2 commit 6830ff8

1 file changed

Lines changed: 6 additions & 4 deletions

File tree

drivers/infiniband/hw/mthca/mthca_cq.c

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -803,8 +803,10 @@ int mthca_init_cq(struct mthca_dev *dev, int nent,
803803
}
804804

805805
mailbox = mthca_alloc_mailbox(dev, GFP_KERNEL);
806-
if (IS_ERR(mailbox))
806+
if (IS_ERR(mailbox)) {
807+
err = PTR_ERR(mailbox);
807808
goto err_out_arm;
809+
}
808810

809811
cq_context = mailbox->buf;
810812

@@ -846,9 +848,9 @@ int mthca_init_cq(struct mthca_dev *dev, int nent,
846848
}
847849

848850
spin_lock_irq(&dev->cq_table.lock);
849-
if (mthca_array_set(&dev->cq_table.cq,
850-
cq->cqn & (dev->limits.num_cqs - 1),
851-
cq)) {
851+
err = mthca_array_set(&dev->cq_table.cq,
852+
cq->cqn & (dev->limits.num_cqs - 1), cq);
853+
if (err) {
852854
spin_unlock_irq(&dev->cq_table.lock);
853855
goto err_out_free_mr;
854856
}

0 commit comments

Comments
 (0)