Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

net/mlx5: Check device memory pointer before usage

Add a NULL check before accessing device memory to prevent a crash if
dev->dm allocation in mlx5_init_once() fails.

Fixes: c9b9dcb430b3 ("net/mlx5: Move device memory management to mlx5_core")
Signed-off-by: Stav Aviram <saviram@nvidia.com>
Link: https://patch.msgid.link/c88711327f4d74d5cebc730dc629607e989ca187.1751370035.git.leon@kernel.org
Signed-off-by: Leon Romanovsky <leon@kernel.org>

authored by

Stav Aviram and committed by
Leon Romanovsky
70f238c9 02943ac2

+3 -6
+1 -1
drivers/infiniband/hw/mlx5/dm.c
··· 282 282 int err; 283 283 u64 address; 284 284 285 - if (!MLX5_CAP_DEV_MEM(dm_db->dev, memic)) 285 + if (!dm_db || !MLX5_CAP_DEV_MEM(dm_db->dev, memic)) 286 286 return ERR_PTR(-EOPNOTSUPP); 287 287 288 288 dm = kzalloc(sizeof(*dm), GFP_KERNEL);
+2 -2
drivers/net/ethernet/mellanox/mlx5/core/lib/dm.c
··· 30 30 31 31 dm = kzalloc(sizeof(*dm), GFP_KERNEL); 32 32 if (!dm) 33 - return ERR_PTR(-ENOMEM); 33 + return NULL; 34 34 35 35 spin_lock_init(&dm->lock); 36 36 ··· 96 96 err_steering: 97 97 kfree(dm); 98 98 99 - return ERR_PTR(-ENOMEM); 99 + return NULL; 100 100 } 101 101 102 102 void mlx5_dm_cleanup(struct mlx5_core_dev *dev)
-3
drivers/net/ethernet/mellanox/mlx5/core/main.c
··· 1102 1102 } 1103 1103 1104 1104 dev->dm = mlx5_dm_create(dev); 1105 - if (IS_ERR(dev->dm)) 1106 - mlx5_core_warn(dev, "Failed to init device memory %ld\n", PTR_ERR(dev->dm)); 1107 - 1108 1105 dev->tracer = mlx5_fw_tracer_create(dev); 1109 1106 dev->hv_vhca = mlx5_hv_vhca_create(dev); 1110 1107 dev->rsc_dump = mlx5_rsc_dump_create(dev);