Received: by 2002:a05:6a10:16a7:0:0:0:0 with SMTP id gp39csp927355pxb; Thu, 19 Nov 2020 18:08:12 -0800 (PST) X-Google-Smtp-Source: ABdhPJxCRfy72hsKkIUSU4DzNRIkHoKTgKML97LdBeuFA1zGc2ok/E3AuomcjnFoYBrMkXihVWPj X-Received: by 2002:a17:906:ae88:: with SMTP id md8mr30129377ejb.323.1605838092170; Thu, 19 Nov 2020 18:08:12 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1605838092; cv=none; d=google.com; s=arc-20160816; b=DoOmQD71jQokNQV8XWqJvRKaPG+VCBxTB1MJNRpOJd/xnqKuir7E/VVzy5U/Pqc+kk ySuOqecLcxr8JWwtLJCklMjaX6rgtwQKc93ppKgemOsJIf13a0Ww4TMSXY2ynzVdGoUY W3sn3yW+7vvP/KWbUlump9e5epOz2eitMCE/ZC6PLXLznaQOCXWNE41xjXvuqueFufSX WQHMlwrkcJ4+5uLfahOVelMNhpIgxtooUYJtT84Recg8L/Gxv3/H4GIFVkOiXPJREUaP jckKiDGDvNDsBdOKnbnUJCn0bLZNikH4t90Jc5+pM+EMUfzF6iigN0vvqwro6hTnkg/r +w7Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:message-id:date:subject:cc:to:from; bh=KqbH0DcDzzqZcHQl5PIOaJkNGB6GQZ3xRzErZdb7eNA=; b=OtZCM6Kb4WI43mogG2HJensqmFGc9e3ztk6fny0pqmuA9hNPaaVeWZFsul7z+8CCk2 pcPR9yjAbOM+IeqUO8k+aPX4zYKvxT1yB+M6NeonQBmJthdBNTUfGGOTaY221M/es/RS OxfZgjp7B35y3eqIdfVHzUM9uSinbXtpBsDtMZS683qee147HLw4RcZlEdYjs1f0XUul UGX0dM+Z52m989Nry4f4XNDg2Rc0Vh+5OwfuYO0hOA/qBMrSz6efWS0j4WRi7OMcv6y1 ZSJoT9/odxFBWhiY1yZD8osdpImGhP0+cUD0Fu0H/ISQ/60OHWBGGLqvv/ZeWCBOmPAD FJDw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id cf25si949159edb.205.2020.11.19.18.07.47; Thu, 19 Nov 2020 18:08:12 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726297AbgKTCFk (ORCPT + 99 others); Thu, 19 Nov 2020 21:05:40 -0500 Received: from szxga06-in.huawei.com ([45.249.212.32]:7956 "EHLO szxga06-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725890AbgKTCFk (ORCPT ); Thu, 19 Nov 2020 21:05:40 -0500 Received: from DGGEMS405-HUB.china.huawei.com (unknown [172.30.72.58]) by szxga06-in.huawei.com (SkyGuard) with ESMTP id 4CcfyY41yqzhc1f; Fri, 20 Nov 2020 10:05:25 +0800 (CST) Received: from linux-ibm.site (10.175.102.37) by DGGEMS405-HUB.china.huawei.com (10.3.19.205) with Microsoft SMTP Server id 14.3.487.0; Fri, 20 Nov 2020 10:05:27 +0800 From: Xiongfeng Wang To: , CC: , , Subject: [PATCH v2] IB/mthca: fix return value of error branch in mthca_init_cq() Date: Fri, 20 Nov 2020 09:57:02 +0800 Message-ID: <1605837422-42724-1-git-send-email-wangxiongfeng2@huawei.com> X-Mailer: git-send-email 1.7.12.4 MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.175.102.37] X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-kernel@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. Fixes: 74c2174e7be5 ("IB uverbs: add mthca user CQ support") Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2") Reported-by: Hulk Robot Signed-off-by: Xiongfeng Wang --- 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