In the previous while loop, "ret" may be assigned zero. Therefore,
"ret" needs to be assigned -EINVAL at the beginning of each loop.
Fixes: 97167e813415 ("staging/rdma/hfi1: Tune for unknown channel if configuration file is absent")
Signed-off-by: Wang Yufen <[email protected]>
---
drivers/infiniband/hw/hfi1/firmware.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/drivers/infiniband/hw/hfi1/firmware.c b/drivers/infiniband/hw/hfi1/firmware.c
index 1d77514..c179dfe 100644
--- a/drivers/infiniband/hw/hfi1/firmware.c
+++ b/drivers/infiniband/hw/hfi1/firmware.c
@@ -1788,6 +1788,7 @@ int parse_platform_config(struct hfi1_devdata *dd)
* being used.
*/
while (ptr < (u32 *)(dd->platform_config.data + file_length)) {
+ ret = -EINVAL;
header1 = *ptr;
header2 = *(ptr + 1);
if (header1 != ~header2) {
--
1.8.3.1
On Fri, Nov 25, 2022 at 08:03:50PM +0800, Wang Yufen wrote:
> In the previous while loop, "ret" may be assigned zero. Therefore,
> "ret" needs to be assigned -EINVAL at the beginning of each loop.
...
> while (ptr < (u32 *)(dd->platform_config.data + file_length)) {
> + ret = -EINVAL;
> header1 = *ptr;
> header2 = *(ptr + 1);
> if (header1 != ~header2) {
You may do it differently and simplify even existing code, i.e.
// The following two lines to add
bali_with_einval:
ret = -EINVAL;
bail:
memset(pcfgcache, 0, sizeof(struct platform_config_cache));
return ret;
Then you convert all goto bail; to goto bail_with_einval; where it's
appropriate. And dropping some duplicative ret = -EINVAL; lines above.
--
With Best Regards,
Andy Shevchenko