[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <Y4SiPfXbMoSc1E6M@unreal>
Date: Mon, 28 Nov 2022 13:57:49 +0200
From: Leon Romanovsky <leon@...nel.org>
To: Wang Yufen <wangyufen@...wei.com>
Cc: bvanassche@....org, jgg@...pe.ca,
dennis.dalessandro@...nelisnetworks.com,
linux-rdma@...r.kernel.org, linux-kernel@...r.kernel.org,
andriy.shevchenko@...ux.intel.com, bart.vanassche@....com,
easwar.hariharan@...el.com
Subject: Re: [PATCH v3 1/2] RDMA/hfi1: Fix error return code in
parse_platform_config()
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 <wangyufen@...wei.com>
> Reviewed-by: Andy Shevchenko <andriy.shevchenko@...ux.intel.com>
> ---
> 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.
Thanks
> bail:
> memset(pcfgcache, 0, sizeof(struct platform_config_cache));
> return ret;
> --
> 1.8.3.1
>
Powered by blists - more mailing lists