mirror of
https://github.com/torvalds/linux.git
synced 2026-05-24 15:12:13 +02:00
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: c9b9dcb430 ("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>
This commit is contained in:
parent
02943ac2f6
commit
70f238c902
|
|
@ -282,7 +282,7 @@ static struct ib_dm *handle_alloc_dm_memic(struct ib_ucontext *ctx,
|
|||
int err;
|
||||
u64 address;
|
||||
|
||||
if (!MLX5_CAP_DEV_MEM(dm_db->dev, memic))
|
||||
if (!dm_db || !MLX5_CAP_DEV_MEM(dm_db->dev, memic))
|
||||
return ERR_PTR(-EOPNOTSUPP);
|
||||
|
||||
dm = kzalloc(sizeof(*dm), GFP_KERNEL);
|
||||
|
|
|
|||
|
|
@ -30,7 +30,7 @@ struct mlx5_dm *mlx5_dm_create(struct mlx5_core_dev *dev)
|
|||
|
||||
dm = kzalloc(sizeof(*dm), GFP_KERNEL);
|
||||
if (!dm)
|
||||
return ERR_PTR(-ENOMEM);
|
||||
return NULL;
|
||||
|
||||
spin_lock_init(&dm->lock);
|
||||
|
||||
|
|
@ -96,7 +96,7 @@ struct mlx5_dm *mlx5_dm_create(struct mlx5_core_dev *dev)
|
|||
err_steering:
|
||||
kfree(dm);
|
||||
|
||||
return ERR_PTR(-ENOMEM);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void mlx5_dm_cleanup(struct mlx5_core_dev *dev)
|
||||
|
|
|
|||
|
|
@ -1102,9 +1102,6 @@ static int mlx5_init_once(struct mlx5_core_dev *dev)
|
|||
}
|
||||
|
||||
dev->dm = mlx5_dm_create(dev);
|
||||
if (IS_ERR(dev->dm))
|
||||
mlx5_core_warn(dev, "Failed to init device memory %ld\n", PTR_ERR(dev->dm));
|
||||
|
||||
dev->tracer = mlx5_fw_tracer_create(dev);
|
||||
dev->hv_vhca = mlx5_hv_vhca_create(dev);
|
||||
dev->rsc_dump = mlx5_rsc_dump_create(dev);
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user