net/mlxfw: fix a NULL dereference
PATCH 1/1 net/mlxfw: fix a NULL dereference
If we hit this error path we end up returning ERR_PTR(0) which is NULL. The caller is not expecting that so it results in a NULL dereference.
Fixes 410ed13cae39 ("Add the mlxfw module for Mellanox firmware flash process")
Signed-off-by Dan Carpenter <[email protected]>
drivers/net/ethernet/mellanox/mlxfw/mlxfw_mfa2.c +1 -0
@@ -594,6 +594,7 @@ struct mlxfw_mfa2_component *if (memcmp (comp_data->buff, mlxfw_mfa2_comp_magic, mlxfw_mfa2_comp_magic_len) !=0 ) {pr_err ("Component has wrong magic\n" ); + err = -EINVAL ; goto err_out; }
Quoted 11 lines · Dan Carpenter
If we hit this error path we end up returning
ERR_PTR(0)which is NULL. The caller is not expecting that so it results in a NULL dereference.Fixes 410ed13cae39 ("Add the mlxfw module for Mellanox firmware flash process")Signed-off-by Dan Carpenter <[email protected]>drivers/net/ethernet/mellanox/mlxfw/mlxfw_mfa2.c +0
-0
drivers/net/ethernet/mellanox/mlxfw/mlxfw_mfa2.c struct mlxfw_mfa2_component * · line 600
Quoted 7 lines
drivers/net/ethernet/mellanox/mlxfw/mlxfw_mfa2.c +1
-0@@ -594,6 +594,7 @@ struct mlxfw_mfa2_component *if (memcmp (comp_data->buff, mlxfw_mfa2_comp_magic, mlxfw_mfa2_comp_magic_len) !=0 ) {pr_err ("Component has wrong magic\n" ); + err = -EINVAL ; goto err_out; }
Acked-by Yotam Gigi <[email protected]>
From: Dan Carpenter <[email protected]>
Date: Wed, 14 Jun 2017 13:41:52 +0300
Quoted 5 lines
If we hit this error path we end up returning
ERR_PTR(0)which is NULL. The caller is not expecting that so it results in a NULL dereference.Fixes 410ed13cae39 ("Add the mlxfw module for Mellanox firmware flash process")Signed-off-by Dan Carpenter <[email protected]>
Applied.