Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp4301288pxu; Tue, 1 Dec 2020 01:17:02 -0800 (PST) X-Google-Smtp-Source: ABdhPJzqZUOXN/wK+TmwBFgyNAxQecfrSUIF3s5pjm9b4/pVmu76oQvJVvM/DZJ4BtG0ELpuWqeV X-Received: by 2002:a17:906:2818:: with SMTP id r24mr2030338ejc.100.1606814222558; Tue, 01 Dec 2020 01:17:02 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1606814222; cv=none; d=google.com; s=arc-20160816; b=kqi9o8w8gzHkrqaF4HGWGif+0YdNvoHERaYOSxaZpgvcH2ya4puh/PHoCqE/5maaRI 2U0/HvX5LhpFzst8vc23gfJexbU6jVpOVRtdi5M19kbW3YDrWBnn8WJq7K5fRhjNt0iw fgJaoxcEZhC8SzRVX8ocI1N1jnD5g/mIKDHpKRRUL8q24CTfVqf4jhMph9ecH4+R5VPF 9Upp8zRMGPslCADCUaGGJJeZ7d4YARMrWWiAwlw3D9I3yUn6h9anwJZdh2sYeLHtemj+ 0NfJTk2xxwHMn+EP7+FZrcgNafNX7OtQozBpVZZxLVyezngFWIFch5R8wdwNkIzLL/23 XgZQ== 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=N0y8HL3WLMkUivZB3ulZgmbyQitD4OdlCXDIcMfmsgVIk5sohvfJpkq/nwZO37hWXm 1TFO1ix9Egl4L1tyrxQs9h7/XEOmTSqPCSPhpuVbY542a851ycKYfG9ViHqx8uHmS727 FHU4Lz9tXk8fgR5D0KKF1EYrh20Ch41ezMEKgOpPHwBqrkfYw6Iko3h2PL7PeO6vp9Gd VNhMCF/kxJWQ+K5CU5HG1tQqoKuEuk+x8a3J8IiwE4hy7ZeWZsdyoXs1h+7SQeUGjLJP fNCqrjgzxzEMds6D1T3y48PYw8WO6548TiU4d4adlbUXz0H0WArDWdyQ+58lnj1c11fe +4Vw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=2S31Rktb; 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 se3si520182ejb.527.2020.12.01.01.16.38; Tue, 01 Dec 2020 01:17:02 -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=2S31Rktb; 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 S2389997AbgLAJMn (ORCPT + 99 others); Tue, 1 Dec 2020 04:12:43 -0500 Received: from mail.kernel.org ([198.145.29.99]:50812 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2389986AbgLAJMk (ORCPT ); Tue, 1 Dec 2020 04:12:40 -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 655AB20809; Tue, 1 Dec 2020 09:11:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1606813920; bh=+ZAL0S7uoDsCPgfkCiQpBraMg5FiTTFCPN+HIpKhNNY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=2S31Rktbe/BuAbFj9YG86EbEACaTKM/07RND+KccBy0y6tJhJbuSiLz93LO2Pdr6M LN52+nXMYdYbbHFN+BArz+X9MCVHPS5puDQpEBT+vScOi4cqMa1dY0lH+3bjCCw/DY HL3fY0iGZPtIcVzCxUZLJMzggpdPkyXbSj4VFyrc= 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.9 104/152] IB/mthca: fix return value of error branch in mthca_init_cq() Date: Tue, 1 Dec 2020 09:53:39 +0100 Message-Id: <20201201084725.464170477@linuxfoundation.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201201084711.707195422@linuxfoundation.org> References: <20201201084711.707195422@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