Skip to content

Commit c0e7327

Browse files
Nikita ZhandarovichPaolo Abeni
authored andcommitted
mlxfw: fix null-ptr-deref in mlxfw_mfa2_tlv_next()
Function mlxfw_mfa2_tlv_multi_get() returns NULL if 'tlv' in question does not pass checks in mlxfw_mfa2_tlv_payload_get(). This behaviour may lead to NULL pointer dereference in 'multi->total_len'. Fix this issue by testing mlxfw_mfa2_tlv_multi_get()'s return value against NULL. Found by Linux Verification Center (linuxtesting.org) with static analysis tool SVACE. Fixes: 410ed13 ("Add the mlxfw module for Mellanox firmware flash process") Co-developed-by: Natalia Petrova <[email protected]> Signed-off-by: Nikita Zhandarovich <[email protected]> Reviewed-by: Ido Schimmel <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Paolo Abeni <[email protected]>
1 parent 28e63d0 commit c0e7327

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@ mlxfw_mfa2_tlv_next(const struct mlxfw_mfa2_file *mfa2_file,
3131

3232
if (tlv->type == MLXFW_MFA2_TLV_MULTI_PART) {
3333
multi = mlxfw_mfa2_tlv_multi_get(mfa2_file, tlv);
34+
if (!multi)
35+
return NULL;
3436
tlv_len = NLA_ALIGN(tlv_len + be16_to_cpu(multi->total_len));
3537
}
3638

0 commit comments

Comments
 (0)