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@xxxxxxxxxx>
Reviewed-by: Andy Shevchenko <andriy.shevchenko@xxxxxxxxxxxxxxx>
---
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