Skip to content

Commit 30e9e05

Browse files
Eran Ben ElishaSaeed Mahameed
authored andcommitted
net/mlxfw: Verify FSM error code translation doesn't exceed array size
Array mlxfw_fsm_state_err_str contains value to string translation, when values are provided by mlxfw_dev. If value is larger than MLXFW_FSM_STATE_ERR_MAX, return "unknown error" as expected instead of reading an address than exceed array size. Fixes: 410ed13 ("Add the mlxfw module for Mellanox firmware flash process") Signed-off-by: Eran Ben Elisha <[email protected]> Acked-by: Jiri Pirko <[email protected]> Signed-off-by: Saeed Mahameed <[email protected]>
1 parent b7eca94 commit 30e9e05

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

drivers/net/ethernet/mellanox/mlxfw/mlxfw_fsm.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,8 @@ static int mlxfw_fsm_state_wait(struct mlxfw_dev *mlxfw_dev, u32 fwhandle,
6666
return err;
6767

6868
if (fsm_state_err != MLXFW_FSM_STATE_ERR_OK) {
69+
fsm_state_err = min_t(enum mlxfw_fsm_state_err,
70+
fsm_state_err, MLXFW_FSM_STATE_ERR_MAX);
6971
pr_err("Firmware flash failed: %s\n",
7072
mlxfw_fsm_state_err_str[fsm_state_err]);
7173
NL_SET_ERR_MSG_MOD(extack, "Firmware flash failed");

0 commit comments

Comments
 (0)