From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 98785C4708B for ; Tue, 29 Nov 2022 01:30:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235076AbiK2Bag (ORCPT ); Mon, 28 Nov 2022 20:30:36 -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 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 >>