Skip to content

Commit 5a20283

Browse files
wangyufen316gregkh
authored andcommitted
RDMA/hfi1: Fix error return code in parse_platform_config()
[ Upstream commit 725349f ] In the previous iteration of the while loop, the "ret" may have been assigned a value of 0, so the error return code -EINVAL may have been incorrectly set to 0. To fix set valid return code before calling to goto. Fixes: 97167e8 ("staging/rdma/hfi1: Tune for unknown channel if configuration file is absent") Signed-off-by: Wang Yufen <wangyufen@huawei.com> Link: https://lore.kernel.org/r/1669953638-11747-1-git-send-email-wangyufen@huawei.com Signed-off-by: Leon Romanovsky <leon@kernel.org> Signed-off-by: Sasha Levin <sashal@kernel.org>
1 parent 7917484 commit 5a20283

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

drivers/infiniband/hw/hfi1/firmware.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1786,6 +1786,7 @@ int parse_platform_config(struct hfi1_devdata *dd)
17861786

17871787
if (!dd->platform_config.data) {
17881788
dd_dev_err(dd, "%s: Missing config file\n", __func__);
1789+
ret = -EINVAL;
17891790
goto bail;
17901791
}
17911792
ptr = (u32 *)dd->platform_config.data;
@@ -1794,6 +1795,7 @@ int parse_platform_config(struct hfi1_devdata *dd)
17941795
ptr++;
17951796
if (magic_num != PLATFORM_CONFIG_MAGIC_NUM) {
17961797
dd_dev_err(dd, "%s: Bad config file\n", __func__);
1798+
ret = -EINVAL;
17971799
goto bail;
17981800
}
17991801

@@ -1817,6 +1819,7 @@ int parse_platform_config(struct hfi1_devdata *dd)
18171819
if (file_length > dd->platform_config.size) {
18181820
dd_dev_info(dd, "%s:File claims to be larger than read size\n",
18191821
__func__);
1822+
ret = -EINVAL;
18201823
goto bail;
18211824
} else if (file_length < dd->platform_config.size) {
18221825
dd_dev_info(dd,
@@ -1837,6 +1840,7 @@ int parse_platform_config(struct hfi1_devdata *dd)
18371840
dd_dev_err(dd, "%s: Failed validation at offset %ld\n",
18381841
__func__, (ptr - (u32 *)
18391842
dd->platform_config.data));
1843+
ret = -EINVAL;
18401844
goto bail;
18411845
}
18421846

@@ -1883,6 +1887,7 @@ int parse_platform_config(struct hfi1_devdata *dd)
18831887
__func__, table_type,
18841888
(ptr - (u32 *)
18851889
dd->platform_config.data));
1890+
ret = -EINVAL;
18861891
goto bail; /* We don't trust this file now */
18871892
}
18881893
pcfgcache->config_tables[table_type].table = ptr;
@@ -1907,6 +1912,7 @@ int parse_platform_config(struct hfi1_devdata *dd)
19071912
__func__, table_type,
19081913
(ptr -
19091914
(u32 *)dd->platform_config.data));
1915+
ret = -EINVAL;
19101916
goto bail; /* We don't trust this file now */
19111917
}
19121918
pcfgcache->config_tables[table_type].table_metadata =

0 commit comments

Comments
 (0)