vdpa/mlx5: Avoid processing works if workqueue was destroyed
authorEli Cohen <elic@nvidia.com>
Mon, 21 Mar 2022 14:13:03 +0000 (16:13 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 12 Jul 2022 14:34:59 +0000 (16:34 +0200)
commit09674bfd8054b6d3667f7db8489551d3c8c1e3d9
treec785e0ce2d06a9d455e407966ac779a651b37ea2
parent008e29d172ca0a4f2f7147b64b06bbaa537500f8
vdpa/mlx5: Avoid processing works if workqueue was destroyed

[ Upstream commit ad6dc1daaf29f97f23cc810d60ee01c0e83f4c6b ]

If mlx5_vdpa gets unloaded while a VM is running, the workqueue will be
destroyed. However, vhost might still have reference to the kick
function and might attempt to push new works. This could lead to null
pointer dereference.

To fix this, set mvdev->wq to NULL just before destroying and verify
that the workqueue is not NULL in mlx5_vdpa_kick_vq before attempting to
push a new work.

Fixes: 5262912ef3cf ("vdpa/mlx5: Add support for control VQ and MAC setting")
Signed-off-by: Eli Cohen <elic@nvidia.com>
Link: https://lore.kernel.org/r/20220321141303.9586-1-elic@nvidia.com
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/vdpa/mlx5/net/mlx5_vnet.c