Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp408357pxu; Tue, 1 Dec 2020 14:31:25 -0800 (PST) X-Google-Smtp-Source: ABdhPJz1+JUo0TfbQEiJYp6t45X3+aBvYIXFgCv3nur2v6IEAcjSYnjRIJCObSxAHZ6JK7eKltq9 X-Received: by 2002:a05:6402:1d24:: with SMTP id dh4mr2752365edb.161.1606861885170; Tue, 01 Dec 2020 14:31:25 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1606861885; cv=none; d=google.com; s=arc-20160816; b=LmfYaC99hnL/5pJoG1aSKHGenIZE5fMLCYfWwxE4/dHDG29lHmRXzy0ssJo1PqR+/g stoMMB9OtkrKUW1O/dehnMfymZYYRDGkPi9SmeIRVKhP/qCAiqDTurE++jzGjOYneLt0 qXos8sf0ZkNucjJsUj2KrY59WyZZ+6pUtMLh+AjNevlsgRxJTqgAIk1aPctoC6YHjqVG 5zAb9VfMd3/v3oETUiI2VrYcI2RmOSirIRVKI2l0bqs24L6EBwgd3lUc8RZeNFBSgHKO kR0agqfh0LpYhDix6HeHOxIeJH18AmiR8wZyhqpg9SvRmL9/wcoQ5hjDeRJ0qNo/S5Ei 51Cw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=XzTQXKh5fIvwB1oaCMFUzOXS8meC0jJ7MGJAMWgKJEc=; b=ZBl4yTEsTWzgSvFm2uo6HptE2L/FujsuXOWIH8PfUMYUyvIs67CulFO+ZLN20rDgAb 3EmBI8rTlRtzHS+AXIGIU+S4TOgP7KA+Cx8wpDVHgj38TEnB0TM+eK59I7mZ5EdqjinO /uiImRT3oidLCsLBHfvBjaj4lcPYNTxDg2F/w58DOjhUOgqtfzb65tk+rpl5fdxgP814 gLLS/WOngWV8PljbWnLvaNSLXXgoun2lTLxXc1pZ1BikKguVOkMTzNuAGTZeSBEfllgF ufgjMfNyhWdoRLW+N8CjGxo7g2ICJmQhhd9IdObxm60FlkmOP/QRsKiDUeFQStuX9HAW Nv8g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=djR0zlow; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id os24si820222ejb.680.2020.12.01.14.31.02; Tue, 01 Dec 2020 14:31:25 -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; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=djR0zlow; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2390727AbgLAJWv (ORCPT + 99 others); Tue, 1 Dec 2020 04:22:51 -0500 Received: from mail.kernel.org ([198.145.29.99]:44102 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388960AbgLAJHT (ORCPT ); Tue, 1 Dec 2020 04:07:19 -0500 Received: from localhost (83-86-74-64.cable.dynamic.v4.ziggo.nl [83.86.74.64]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id EABB421D46; Tue, 1 Dec 2020 09:06:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1606813590; bh=+ZAL0S7uoDsCPgfkCiQpBraMg5FiTTFCPN+HIpKhNNY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=djR0zlowtJwDMaVE2BbIwdijcOSPjxajUUGPA0K+91RxorQAOhUVfhg5dWkj/hx2o KZ1CAyw3J9jPY64TFAqn5sm0oP75a2FoDwRoemCdPTIigQx86ESBX8dYBozJoyQcgl ZR/eoasz/SgzqDQbi/FzpLyPPbsHGE7KEusxqJTA= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Hulk Robot , Xiongfeng Wang , Jason Gunthorpe , Sasha Levin Subject: [PATCH 5.4 61/98] IB/mthca: fix return value of error branch in mthca_init_cq() Date: Tue, 1 Dec 2020 09:53:38 +0100 Message-Id: <20201201084658.069326923@linuxfoundation.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201201084652.827177826@linuxfoundation.org> References: <20201201084652.827177826@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Xiongfeng Wang [ Upstream commit 6830ff853a5764c75e56750d59d0bbb6b26f1835 ] 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") Link: https://lore.kernel.org/r/1605837422-42724-1-git-send-email-wangxiongfeng2@huawei.com Reported-by: Hulk Robot Signed-off-by: Xiongfeng Wang Signed-off-by: Jason Gunthorpe Signed-off-by: Sasha Levin --- 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 c3cfea243af8c..119b2573c9a08 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; } -- 2.27.0