Skip to contentSkip to conversation

vdpa/mlx5: Verify wq is a valid pointer in mlx5_vdpa_suspend

PATCH Michael S. Tsirkin 1 participant 1 message Apr 4, 2023 1 message not in the archive virtio core

lore
Share & tools
lore

Michael S. Tsirkin

author maintainer
#1 lore raw
In reply to a message not in the archive
Quoted 9 lines · Eli Cohen

mlx5_vdpa_suspend() flushes the workqueue as part of its logic. However, if the device has been deleted while a VM was running, the workqueue will be destroyed first and wq will become null. After the VM is destroyed, suspend can be called and will access a null pointer.

Fix it by verifying wq is not NULL.

Fixes cae15c2ed8e6 ("vdpa/mlx5: Implement susupend virtqueue callback")

This conflicts with the patch for not losing link state updates. How do you want to handle this?

Quoted 23 lines

---
v1 -> v2:
Fix spelling errors

 drivers/vdpa/mlx5/net/mlx5_vnet.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/vdpa/mlx5/net/mlx5_vnet.c +2 -1
index 85866ace0061..b73c5943aefd 100644
@@ -2929,7 +2929,8 @@ static int mlx5_vdpa_suspend(struct vdpa_device *vdev)
 	down_write(&ndev->reslock);
 	ndev->nb_registered = false;
 	mlx5_notifier_unregister(mvdev->mdev, &ndev->nb);
-	flush_workqueue(ndev->mvdev.wq);
+	if (ndev->mvdev.wq)
+		flush_workqueue(ndev->mvdev.wq);
 	for (i = 0; i < ndev->cur_num_vqs; i++) {
 		mvq = &ndev->vqs[i];
 		suspend_vq(ndev, mvq);
Signature · 1 line
2.38.1

_______________________________________________
Virtualization mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/virtualization