Received: by 2002:a05:6a10:16a7:0:0:0:0 with SMTP id gp39csp920241pxb; Thu, 19 Nov 2020 17:55:15 -0800 (PST) X-Google-Smtp-Source: ABdhPJwBDVtLNSk+Ajmgh+cJitItGJ3tOFBhN4LCjDiKq6rHtCqeveOkSsmiluCUQsJqHVqq6w29 X-Received: by 2002:a17:906:bc9a:: with SMTP id lv26mr29913870ejb.409.1605837315127; Thu, 19 Nov 2020 17:55:15 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1605837315; cv=none; d=google.com; s=arc-20160816; b=YISue3Q7w6hMsth/39WUuONkjF22Q9g0x74UoVOPYXmnXxSCTk+nQ9DhRJQ5Bt4+jl TG2aCBkQBXCcjM0jlpl/ljP7RdL1bWo4mWmop7jW2RVRmB/qNvsaYlVKrXpjsL/SdUx6 QmnMedXX8C/x9hB28h2MvsdxoeGilqqC9+3Z95jgLtO7gbC5cCFeCjCDFgm7c+UdF9Qy ARoV+xojL5gFgKlQO9b+mNn2ilz8GFiGpfDkwiRJhXwZErut8SLirr9pjfklQYVx6Ybx LejymAAmJfw6J5+3JIN+ZtzvemaLb8m3AneibEuayVcqZCLGcz9PypRwo2Sn0JlPOuRq 1ehg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to :mime-version:user-agent:date:message-id:from:references:cc:to :subject; bh=z1hx5LlA2uLEdLkCxQBpbFdYlQSh41buJygOg7BXc0E=; b=EBPiLBVVuPKk8YyN7wVbv6tGTb9YEg/3GaP617ML8VU7yWxXaBoWDfmYJG+I2drVdC fpEv6mSL/2a3RXdN5GMcCLYxSE1w8XYMGRYTc6+h2RfCcJwKZ3BcjaXp3PDAQvQi4xJX 43S8hKh1OZ+su3FLjysLikE8wSzvUjp86kqHQ2u61iO4PxO7M8FZA+YZfgYCJwp8kPtg MWvkd4T9T4q/59MkTfx+4HW3e6y8odLigJpLy6yfmqbYhZ0q6I+OUMfV31c/jeB+Efdg kRjstURKMUMlpDWGHsXxlS/v11SrHisgola12lA66RF6hL8AqTOpweRow6T9OfS3e7m8 VqMg== 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 z34si918725ede.351.2020.11.19.17.54.51; Thu, 19 Nov 2020 17:55:15 -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 S1726485AbgKTBvT (ORCPT + 99 others); Thu, 19 Nov 2020 20:51:19 -0500 Received: from szxga05-in.huawei.com ([45.249.212.191]:8123 "EHLO szxga05-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726365AbgKTBvT (ORCPT ); Thu, 19 Nov 2020 20:51:19 -0500 Received: from DGGEMS412-HUB.china.huawei.com (unknown [172.30.72.60]) by szxga05-in.huawei.com (SkyGuard) with ESMTP id 4Ccfdr1PC6zLqcx; Fri, 20 Nov 2020 09:50:56 +0800 (CST) Received: from [10.174.177.160] (10.174.177.160) by DGGEMS412-HUB.china.huawei.com (10.3.19.212) with Microsoft SMTP Server id 14.3.487.0; Fri, 20 Nov 2020 09:51:12 +0800 Subject: Re: [PATCH] IB/mthca: fix return value of error branch in mthca_init_cq() To: Jason Gunthorpe CC: , , References: <1605789529-54808-1-git-send-email-wangxiongfeng2@huawei.com> <20201119153050.GA1960484@nvidia.com> From: Xiongfeng Wang Message-ID: Date: Fri, 20 Nov 2020 09:51:11 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:68.0) Gecko/20100101 Thunderbird/68.4.1 MIME-Version: 1.0 In-Reply-To: <20201119153050.GA1960484@nvidia.com> Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit X-Originating-IP: [10.174.177.160] X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi, Jason Thanks for your reply ! On 2020/11/19 23:30, Jason Gunthorpe wrote: > On Thu, Nov 19, 2020 at 08:38:49PM +0800, Xiongfeng Wang wrote: >> 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 > > Missing fixes line > >> 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; >> + } > > mthca_alloc_mailbox returns err_ptr so this should do > > err = ERR_PTR(mailbox) Is it PTR_ERR here ? Since mailbox is a pointer. > >> 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; > > And this should assign err to the output of mthca_array_set > > Please fix and resend. Sure. Thanks, Xiongfeng > > Thanks, > Jason >