[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <1605789529-54808-1-git-send-email-wangxiongfeng2@huawei.com>
Date: Thu, 19 Nov 2020 20:38:49 +0800
From: Xiongfeng Wang <wangxiongfeng2@...wei.com>
To: <dledford@...hat.com>, <jgg@...pe.ca>
CC: <wangxiongfeng2@...wei.com>, <linux-rdma@...r.kernel.org>,
<linux-kernel@...r.kernel.org>
Subject: [PATCH] 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.
Reported-by: Hulk Robot <hulkci@...wei.com>
Signed-off-by: Xiongfeng Wang <wangxiongfeng2@...wei.com>
---
drivers/infiniband/hw/mthca/mthca_cq.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/drivers/infiniband/hw/mthca/mthca_cq.c b/drivers/infiniband/hw/mthca/mthca_cq.c
index c3cfea2..98d697b 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 = -ENOMEM;
goto err_out_arm;
+ }
cq_context = mailbox->buf;
@@ -850,6 +852,7 @@ int mthca_init_cq(struct mthca_dev *dev, int nent,
cq->cqn & (dev->limits.num_cqs - 1),
cq)) {
spin_unlock_irq(&dev->cq_table.lock);
+ err = -ENOMEM;
goto err_out_free_mr;
}
spin_unlock_irq(&dev->cq_table.lock);
--
1.7.12.4
Powered by blists - more mailing lists