net: mellanox: mlxsw: fix error return code of mlxsw_sp_router_nve_promote_decap()
Subsystems (3)
PATCH 1/1 net: mellanox: mlxsw: fix error return code of mlxsw_sp_router_nve_promote_decap()
When fib_entry is NULL, no error return code of mlxsw_sp_router_nve_promote_decap() is assigned. To fix this bug, err is assigned with -EINVAL in this case.
--- drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c +3 -1
@@ -1981,8 +1981,10 @@ int mlxsw_sp_router_nve_promote_decap(struct mlxsw_sp *mlxsw_sp, u32 ul_tb_id, fib_entry =mlxsw_sp_router_ip2me_fib_entry_find (mlxsw_sp, ul_tb_id, ul_proto, ul_sip, type); -if (!fib_entry) +if (!fib_entry) { + err = -EINVAL ; goto out; + } fib_entry->decap.tunnel_index = tunnel_index; fib_entry->type =MLXSW_SP_FIB_ENTRY_TYPE_NVE_DECAP ;
Signature · 1 line
2.17.1
Quoted 4 lines · Jia-Ju Bai
When
fib_entryis NULL, no error return code ofmlxsw_sp_router_nve_promote_decap()is assigned. To fix this bug, err is assigned with-EINVALin this case.
Again, are you sure this is a bug? To me it looks like it is intentional to not return an error code if fib_entry is NULL. Please don't blindly trust the robot results, there may always be false positives.
Quoted 23 lines
Reported-by TOTE Robot <[email protected]>Signed-off-by Jia-Ju Bai <[email protected]>--- drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c +3
-1@@ -1981,8 +1981,10 @@ int mlxsw_sp_router_nve_promote_decap(struct mlxsw_sp *mlxsw_sp, u32 ul_tb_id, fib_entry =mlxsw_sp_router_ip2me_fib_entry_find (mlxsw_sp, ul_tb_id, ul_proto, ul_sip, type); -if (!fib_entry) +if (!fib_entry) { + err = -EINVAL ; goto out; + } fib_entry->decap.tunnel_index = tunnel_index; fib_entry->type =MLXSW_SP_FIB_ENTRY_TYPE_NVE_DECAP ;
Quoted 9 lines · Heiner Kallweit
Quoted 4 lines · Jia-Ju Bai
When
fib_entryis NULL, no error return code ofmlxsw_sp_router_nve_promote_decap()is assigned. To fix this bug, err is assigned with-EINVALin this case.Again, are you sure this is a bug? To me it looks like it is intentional to not return an error code if
fib_entryis NULL. Please don't blindly trust the robot results, there may always be false positives.
Yes, it is OK not to return an error. There is even a comment above the call to mlxsw_sp_router_ip2me_fib_entry_find():
/* It is valid to create a tunnel with a local IP and only later
* assign this IP address to a local interface
*/
Quoted 25 lines
Quoted 24 lines
Reported-by TOTE Robot <[email protected]>Signed-off-by Jia-Ju Bai <[email protected]>--- drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c +3
-1@@ -1981,8 +1981,10 @@ int mlxsw_sp_router_nve_promote_decap(struct mlxsw_sp *mlxsw_sp, u32 ul_tb_id, fib_entry =mlxsw_sp_router_ip2me_fib_entry_find (mlxsw_sp, ul_tb_id, ul_proto, ul_sip, type); -if (!fib_entry) +if (!fib_entry) { + err = -EINVAL ; goto out; + } fib_entry->decap.tunnel_index = tunnel_index; fib_entry->type =MLXSW_SP_FIB_ENTRY_TYPE_NVE_DECAP ;