]> git.itanic.dy.fi Git - linux-stable/commit
net/mlx5: Devcom, fix error flow in mlx5_devcom_register_device
authorShay Drory <shayd@nvidia.com>
Tue, 2 May 2023 10:35:11 +0000 (13:35 +0300)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 30 May 2023 13:17:28 +0000 (14:17 +0100)
commita3a516caef2c5be2f4d171890a8b3415bfab4e5e
treed9ac145639a37a053ff63209b36a7f5b37fc02ab
parentd8b6f175235d7327b4e1b13216859e89496dfbd5
net/mlx5: Devcom, fix error flow in mlx5_devcom_register_device

commit af87194352cad882d787d06fb7efa714acd95427 upstream.

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: fadd59fc50d0 ("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>
drivers/net/ethernet/mellanox/mlx5/core/lib/devcom.c