linux-rdma.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2] IB/mthca: fix return value of error branch in mthca_init_cq()
@ 2020-11-20  1:57 Xiongfeng Wang
  2020-11-23 20:28 ` Jason Gunthorpe
  0 siblings, 1 reply; 2+ messages in thread
From: Xiongfeng Wang @ 2020-11-20  1:57 UTC (permalink / raw)
  To: dledford, jgg; +Cc: wangxiongfeng2, linux-rdma, linux-kernel

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: 74c2174e7be5 ("IB uverbs: add mthca user CQ support")
Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2")
Reported-by: Hulk Robot <hulkci@huawei.com>
Signed-off-by: Xiongfeng Wang <wangxiongfeng2@huawei.com>
---
 drivers/infiniband/hw/mthca/mthca_cq.c | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/drivers/infiniband/hw/mthca/mthca_cq.c b/drivers/infiniband/hw/mthca/mthca_cq.c
index c3cfea2..119b257 100644
--- a/drivers/infiniband/hw/mthca/mthca_cq.c
+++ b/drivers/infiniband/hw/mthca/mthca_cq.c
@@ -803,8 +803,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;
 
@@ -846,9 +848,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;
 	}
-- 
1.7.12.4


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

* Re: [PATCH v2] IB/mthca: fix return value of error branch in mthca_init_cq()
  2020-11-20  1:57 [PATCH v2] IB/mthca: fix return value of error branch in mthca_init_cq() Xiongfeng Wang
@ 2020-11-23 20:28 ` Jason Gunthorpe
  0 siblings, 0 replies; 2+ messages in thread
From: Jason Gunthorpe @ 2020-11-23 20:28 UTC (permalink / raw)
  To: Xiongfeng Wang; +Cc: dledford, linux-rdma, linux-kernel

On Fri, Nov 20, 2020 at 09:57:02AM +0800, Xiongfeng Wang wrote:
> 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: 74c2174e7be5 ("IB uverbs: add mthca user CQ support")
> Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2")
> Reported-by: Hulk Robot <hulkci@huawei.com>
> Signed-off-by: Xiongfeng Wang <wangxiongfeng2@huawei.com>
> ---
>  drivers/infiniband/hw/mthca/mthca_cq.c | 10 ++++++----
>  1 file changed, 6 insertions(+), 4 deletions(-)

Applied to for-rc, thanks

Jason

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

end of thread, other threads:[~2020-11-23 20:28 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-11-20  1:57 [PATCH v2] IB/mthca: fix return value of error branch in mthca_init_cq() Xiongfeng Wang
2020-11-23 20:28 ` Jason Gunthorpe

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).