Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp114101rwb; Mon, 28 Nov 2022 17:50:40 -0800 (PST) X-Google-Smtp-Source: AA0mqf63tQ7mPisoeSp+7UooGV0DPUw3juhGPqXXK75npei8yKsWl5wQk1OQQ3STcrM8bZNAT/hd X-Received: by 2002:a17:90b:484:b0:218:9d3d:71f4 with SMTP id bh4-20020a17090b048400b002189d3d71f4mr47729065pjb.148.1669686639855; Mon, 28 Nov 2022 17:50:39 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669686639; cv=none; d=google.com; s=arc-20160816; b=uUQQAJWvIf3m+zLTPeCm9cWbr/YXZPOsUftsVh3MSWx9SC391VeNRpK3/B7TvjBPhJ rXcyrrLkV6diaGQBz9xM+ZYxF7scB27dDNjdkx7NHqxkXmgLJWFKOMmRN9EQlgzuwH57 YP5bVQPPljLarqw0Qc+Qzt4zgYniOVRk7z2v0rC/yS8PKe+Q1DxGaEVZa5alifWWH+YS /f0fbI39LxDkY9GfRWrd0pIX2m8tzmKYKZh6R5pfDj9HTtqKceSoUZKBt7peOBiqtewp Yf8F/ULXY7VCLSAoGp7dB9CD5fhhLWix5XhYu0FnYJWnWIwGb//umjSNcGgXrdoQbfVU zOZg== 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:from :references:cc:to:subject:user-agent:mime-version:date:message-id; bh=5lxRUZqgVTyJq7VJCGQvoGcZOUAFb0O9ToQv/68Ieig=; b=LWwNmqgYPvmnLVzBoeziwVnJ2EtjLAcEOgjhfHXtusUudfQB0TFdwahXDz/TJvyS38 CgN9hL8UNq/tqslNcfjOgUpRN3vqcGuCAYxcHv3UTfR1TfXuii+PZduBiONLnBai9jVu vkx50QJrCtSiPbigYVE950/R4ROcqGocNq2qMt+i/7qFXxpoC4o+WVRgXd12CL2oNEK4 s5AdnO1oHb1e/8JeQ5dm2lXN5vihcebyR6wAE36kz3qPvvhy+aIR2aa7EnCewVPNJzlI arBZnAmM7oyJPyZRKmwayvgxpqaZoOFQ5A5+loSqHZv150X5xiBYCBCE9MABnrY1w2uv StlQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id 198-20020a6303cf000000b00477c0882415si12582116pgd.58.2022.11.28.17.50.21; Mon, 28 Nov 2022 17:50:39 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235070AbiK2Baf (ORCPT + 82 others); Mon, 28 Nov 2022 20:30:35 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59760 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234828AbiK2Bad (ORCPT ); Mon, 28 Nov 2022 20:30:33 -0500 Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5BF5340934; Mon, 28 Nov 2022 17:30:31 -0800 (PST) Received: from canpemm500010.china.huawei.com (unknown [172.30.72.57]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4NLl6X25tnzqSk0; Tue, 29 Nov 2022 09:26:28 +0800 (CST) Received: from [10.174.179.191] (10.174.179.191) by canpemm500010.china.huawei.com (7.192.105.118) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.31; Tue, 29 Nov 2022 09:30:28 +0800 Message-ID: <632848a1-d363-7a20-8dd3-fae6645fc28d@huawei.com> Date: Tue, 29 Nov 2022 09:30:27 +0800 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101 Thunderbird/102.2.0 Subject: Re: [PATCH v3 1/2] RDMA/hfi1: Fix error return code in parse_platform_config() To: Leon Romanovsky CC: , , , , , , , References: <1669470654-45828-1-git-send-email-wangyufen@huawei.com> From: wangyufen In-Reply-To: Content-Type: text/plain; charset="UTF-8"; format=flowed Content-Transfer-Encoding: 8bit X-Originating-IP: [10.174.179.191] X-ClientProxiedBy: dggems702-chm.china.huawei.com (10.3.19.179) To canpemm500010.china.huawei.com (7.192.105.118) X-CFilter-Loop: Reflected X-Spam-Status: No, score=-4.5 required=5.0 tests=BAYES_00,NICE_REPLY_A, RCVD_IN_DNSWL_MED,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 在 2022/11/28 19:57, Leon Romanovsky 写道: > On Sat, Nov 26, 2022 at 09:50:53PM +0800, Wang Yufen wrote: >> In the previous while loop, "ret" may be assigned zero, so the error >> return code may be incorrectly set to 0 instead of -EINVAL. >> Add bail_with_einval goto label and covert all "goto bail;" to "goto >> bail_with_einval:" where it's appropriate. Add dropping some duplicative >> "ret = -EINVAL;" lines, as Andy suggessted. >> >> Fixes: 97167e813415 ("staging/rdma/hfi1: Tune for unknown channel if configuration file is absent") >> Signed-off-by: Wang Yufen >> Reviewed-by: Andy Shevchenko >> --- >> drivers/infiniband/hw/hfi1/firmware.c | 20 +++++++++++--------- >> 1 file changed, 11 insertions(+), 9 deletions(-) > > <...> > > >> +bail_with_einval: >> + ret = -EINVAL; > > Sorry for being late, but no. It can be seen as anti-pattern as it > causes to the situations where unrelated code changes can potentially > overwrite return value. Please set valid return code before calling to > goto. OK, will change in v4. Thanks > > Thanks > >> bail: >> memset(pcfgcache, 0, sizeof(struct platform_config_cache)); >> return ret; >> -- >> 1.8.3.1 >>