From patchwork Thu Nov 19 12:38:49 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Xiongfeng Wang X-Patchwork-Id: 11917281 X-Patchwork-Delegate: jgg@ziepe.ca Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.7 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 10726C63697 for ; Thu, 19 Nov 2020 12:47:20 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id AAA43246B8 for ; Thu, 19 Nov 2020 12:47:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726407AbgKSMrS (ORCPT ); Thu, 19 Nov 2020 07:47:18 -0500 Received: from szxga07-in.huawei.com ([45.249.212.35]:8374 "EHLO szxga07-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726052AbgKSMrS (ORCPT ); Thu, 19 Nov 2020 07:47:18 -0500 Received: from DGGEMS414-HUB.china.huawei.com (unknown [172.30.72.58]) by szxga07-in.huawei.com (SkyGuard) with ESMTP id 4CcKFH1lmrz70GF; Thu, 19 Nov 2020 20:46:59 +0800 (CST) Received: from linux-ibm.site (10.175.102.37) by DGGEMS414-HUB.china.huawei.com (10.3.19.214) with Microsoft SMTP Server id 14.3.487.0; Thu, 19 Nov 2020 20:47:07 +0800 From: Xiongfeng Wang To: , CC: , , Subject: [PATCH] IB/mthca: fix return value of error branch in mthca_init_cq() Date: Thu, 19 Nov 2020 20:38:49 +0800 Message-ID: <1605789529-54808-1-git-send-email-wangxiongfeng2@huawei.com> X-Mailer: git-send-email 1.7.12.4 MIME-Version: 1.0 X-Originating-IP: [10.175.102.37] X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org 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 Signed-off-by: Xiongfeng Wang --- 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);