mirror of
https://github.com/hardkernel/linux.git
synced 2026-06-06 02:50:49 +09:00
net/mlx5: Devcom, fix error flow in mlx5_devcom_register_device
commitaf87194352upstream. In case devcom allocation is failed, mlx5 is always freeing the priv. However, this priv might have been allocated by a different thread, and freeing it might lead to use-after-free bugs. Fix it by freeing the priv only in case it was allocated by the running thread. Fixes:fadd59fc50("net/mlx5: Introduce inter-device communication mechanism") Signed-off-by: Shay Drory <shayd@nvidia.com> Signed-off-by: Saeed Mahameed <saeedm@nvidia.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
committed by
Greg Kroah-Hartman
parent
411e4d6caa
commit
eaa365c104
@@ -112,7 +112,8 @@ struct mlx5_devcom *mlx5_devcom_register_device(struct mlx5_core_dev *dev)
|
|||||||
priv->devs[idx] = dev;
|
priv->devs[idx] = dev;
|
||||||
devcom = mlx5_devcom_alloc(priv, idx);
|
devcom = mlx5_devcom_alloc(priv, idx);
|
||||||
if (!devcom) {
|
if (!devcom) {
|
||||||
kfree(priv);
|
if (new_priv)
|
||||||
|
kfree(priv);
|
||||||
return ERR_PTR(-ENOMEM);
|
return ERR_PTR(-ENOMEM);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user