Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp409696pxu; Tue, 1 Dec 2020 14:33:48 -0800 (PST) X-Google-Smtp-Source: ABdhPJydqG+ZKRWw9vHk3jl8zyiwC7PH0i9rfwOh1e+E5UqH0b2H9iZagenT4V9DnKSy2dLKxtAq X-Received: by 2002:a17:906:af79:: with SMTP id os25mr5218195ejb.275.1606862027959; Tue, 01 Dec 2020 14:33:47 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1606862027; cv=none; d=google.com; s=arc-20160816; b=zYYt0oEMQ8AgWPidXE343StJXtw5xSJBrppPFBFgh8p2lky88Cuq+gRYp9yTjr7eKF a4VYHuec8OnVv3ZiIijB87KAjT9buWzfYcBi+LQBMYl2Nl2f+7Scu2geA04azESJgUAq 9KIEJ7+gvv6iMzlY/SsRjxEBJMJN8Ta6e/GNgtk3wVDimxKgQxZ1Lf3LyEBcSoViwjMp 3or9SIxxuJQB4hr/TXrYzBOZ03Kjw4wgcfQdCHDOuhNXf8VvvTWdfCK8jBwhNKfJYU0x BeTtHWEfStLXa/btF1TVAcbyPwTMvOlboFh/a1q4UOKhoyP3Lo8LrvAudizUYA9aLn8O 2aUQ== 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=Gfwd5uPV3KjqiMCHjgr9FbR9hhmF2eBr5Mt7J9VLOIY=; b=WB4Xnej+lj8Rp/zOR8JSvSkiCB5NsGxqKeHemes39jU+K5wnYycbal8PaaVbIO0oZF s6KkmaWiXAT2xHB3bxhZFxQsYzl2SPCAVQz2jcSkgpNbvgtaT46Hcrns096/i5a5H9JQ 5T1DN7PNliCnI+4Ko2DaN9bfL4dLbG3BuXy7sT0D5g/QA+51hHBlNxxDNMHNOZ/kxLrE VYAyel0WHmVT7hNbLEowkAhu0UFRcr0UbfT3bfnyv36ikf3ukME7IObsFTU7+filcacN 4SbLHocWy8y6UFcKs++/VTMcAF8KNylprloDJfOyddHVtb1yZOMZF1mDVHE/pWkTEkMO h7JQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=NbkFVLod; 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 x2si795620ejd.604.2020.12.01.14.33.25; Tue, 01 Dec 2020 14:33:47 -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=NbkFVLod; 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 S2391171AbgLAJ3v (ORCPT + 99 others); Tue, 1 Dec 2020 04:29:51 -0500 Received: from mail.kernel.org ([198.145.29.99]:34712 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387593AbgLAI7G (ORCPT ); Tue, 1 Dec 2020 03:59:06 -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 D64A722210; Tue, 1 Dec 2020 08:58:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1606813099; bh=VCawFnsDnQNth3TO+YKU9YQEsIltI4b3xyFvMrV7n4E=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=NbkFVLodG/B8/zLJNZbspW1Ycm2xu0Y94rHcDgyBDsSeKhlVTdBNtcGEsLyabo++5 fA2lyB+z5LzdJje6QOwBPiGSvHhh569rHYLx625Y9k9cSt9u6iRBDyTnHfytbpOpUA BlSEnxB8eiIgfz9Z/Nj7yUeQ1/1CzaaLbQ3nN314= 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 4.14 33/50] IB/mthca: fix return value of error branch in mthca_init_cq() Date: Tue, 1 Dec 2020 09:53:32 +0100 Message-Id: <20201201084649.107348521@linuxfoundation.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201201084644.803812112@linuxfoundation.org> References: <20201201084644.803812112@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 a6531ffe29a6f..a5694dec3f2ee 100644 --- a/drivers/infiniband/hw/mthca/mthca_cq.c +++ b/drivers/infiniband/hw/mthca/mthca_cq.c @@ -808,8 +808,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; @@ -851,9 +853,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