Received: by 2002:a05:6a10:16a7:0:0:0:0 with SMTP id gp39csp417830pxb; Thu, 19 Nov 2020 04:49:56 -0800 (PST) X-Google-Smtp-Source: ABdhPJzCSkf3yj8z3C9PYWY/inlOguVf9f1UgLilRj7VgJQFxyABC0Z1nL3rNK4ChZOgxPmZ5Rsk X-Received: by 2002:a50:e68a:: with SMTP id z10mr1685009edm.28.1605790196226; Thu, 19 Nov 2020 04:49:56 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1605790196; cv=none; d=google.com; s=arc-20160816; b=EpSL57hjBrX6SZfZRyKUZvVJeLl3ZvfCOqv4w75sMXzYOVGBQzSFQhy0f83R3tCtp4 Lsv8GliMmZroQ0u5bA4NQse6sTZfMYvYIsB6Jt3w/joXfUmmiuOZg647DxGLf7slcrBP lymrakdwfL+1VLvQRbIqDfEMlKso1lWdJnLQWaEUgPW4yJEGhdD928kq04eCIGtBzZyP +Y59qn4calWcsolg1pamMdjtRZlgnRKrUIBExgfme3Z6ZISDM2Orp9dTHKfFNadhEzym ptvJ7djB3ztxx98pd8LFHd/PlOkkcy8OkbXKb5qL9Dmxmhn8RA7mrjK/adtmoZ8Z9k9p GwPg== 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=26jPzT1CXMcqSVSF0Hc77vCFrdGGH022wC/agyIa1sY=; b=Ahlq9aChtj8SOGxZLQFA+bXMDhEUc0dcGQe8PVBhkgCnvCWbN8bQn5LuObkUtCd3RS g0YTzuHc3mCwhzk80qLb9cY7TKV7uKyxf4zs60DwInZyINEJ8RxdiOaGOjfV8etz4KHh xfD/pVW70PKuGrpkx0dOkg4KFv4yx/Tr8sQeb2pNFPUP1FF6LWv3suwjtaStgGGrbqNM nMbeRQUnZR1KQO3XOIg4zV48YzdkVMeDHx06CKuTtkLyjd/3kD2cyFQP2Q/cJ37GGfGr bGQlObAm2px3L252b+clIkqHWHMvTnOkSC5tM+WMt5Aqalv7Q0xIqG9HC8c/tB9KsfVX pGQw== 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 l12si3134185edi.88.2020.11.19.04.49.33; Thu, 19 Nov 2020 04:49:56 -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 S1727048AbgKSMrT (ORCPT + 99 others); Thu, 19 Nov 2020 07:47:19 -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 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. 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); -- 1.7.12.4