Skip to content

Commit 7d36a4a

Browse files
gal-pressmankuba-moo
authored andcommitted
net/mlx5e: Fix NULL pointer dereference in ioctl module EEPROM query
The mlx5_query_mcia() function unconditionally dereferences the status pointer to store the MCIA register status value. However, mlx5e_get_module_id() passes NULL since it doesn't need the status value. Add a NULL check before dereferencing the status pointer to prevent a NULL pointer dereference. Fixes: 2e4c44b ("net/mlx5: Refactor EEPROM query error handling to return status separately") Signed-off-by: Gal Pressman <[email protected]> Reviewed-by: Tariq Toukan <[email protected]> Reviewed-by: Dragos Tatulea <[email protected]> Signed-off-by: Mark Bloch <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
1 parent 6c75dc9 commit 7d36a4a

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

  • drivers/net/ethernet/mellanox/mlx5/core

drivers/net/ethernet/mellanox/mlx5/core/port.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -393,9 +393,11 @@ static int mlx5_query_mcia(struct mlx5_core_dev *dev,
393393
if (err)
394394
return err;
395395

396-
*status = MLX5_GET(mcia_reg, out, status);
397-
if (*status)
396+
if (MLX5_GET(mcia_reg, out, status)) {
397+
if (status)
398+
*status = MLX5_GET(mcia_reg, out, status);
398399
return -EIO;
400+
}
399401

400402
ptr = MLX5_ADDR_OF(mcia_reg, out, dword_0);
401403
memcpy(data, ptr, size);

0 commit comments

Comments
 (0)