All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2] vdpa/mlx5: Don't free QP buffers if destroying the QP fails
@ 2026-11-02 20:47 Yuho Choi
  2026-11-02 20:51 ` sashiko-bot
  0 siblings, 1 reply; 2+ messages in thread
From: Yuho Choi @ 2026-11-02 20:47 UTC (permalink / raw)
  To: Dragos Tatulea, Michael S. Tsirkin, Jason Wang,
	Eugenio Pérez
  Cc: Xuan Zhuo, virtualization, linux-kernel, Yuho Choi

qp_destroy() frees the RQ buffer and doorbell record of a driver-owned
QP even when DESTROY_QP fails. The QP then still exists in firmware and
can read WQEs and the doorbell record from freed memory.

Return without freeing them in that case, as cq_destroy() does, and
include the QP type and the error in the warning.

Signed-off-by: Yuho Choi <oss.patchbox@gmail.com>
---
v2:
- Shorten the commit message (Dragos).
- Drop the Fixes and Cc: stable tags (Dragos).
- Print the QP type and the error in the warning (Dragos).
- Rebased on v7.4-rc1.

Compile-tested with W=1.

 drivers/vdpa/mlx5/net/mlx5_vnet.c | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/drivers/vdpa/mlx5/net/mlx5_vnet.c b/drivers/vdpa/mlx5/net/mlx5_vnet.c
index 8563fec2855d..20f4ff67c975 100644
--- a/drivers/vdpa/mlx5/net/mlx5_vnet.c
+++ b/drivers/vdpa/mlx5/net/mlx5_vnet.c
@@ -479,12 +479,18 @@ static int qp_create(struct mlx5_vdpa_net *ndev, struct mlx5_vdpa_virtqueue *mvq
 static void qp_destroy(struct mlx5_vdpa_net *ndev, struct mlx5_vdpa_qp *vqp)
 {
 	u32 in[MLX5_ST_SZ_DW(destroy_qp_in)] = {};
+	int err;
 
 	MLX5_SET(destroy_qp_in, in, opcode, MLX5_CMD_OP_DESTROY_QP);
 	MLX5_SET(destroy_qp_in, in, qpn, vqp->mqp.qpn);
 	MLX5_SET(destroy_qp_in, in, uid, ndev->mvdev.res.uid);
-	if (mlx5_cmd_exec_in(ndev->mvdev.mdev, destroy_qp, in))
-		mlx5_vdpa_warn(&ndev->mvdev, "destroy qp 0x%x\n", vqp->mqp.qpn);
+	err = mlx5_cmd_exec_in(ndev->mvdev.mdev, destroy_qp, in);
+	if (err) {
+		/* The QP still owns its buffers */
+		mlx5_vdpa_warn(&ndev->mvdev, "destroy %s qp 0x%x failed: %d\n",
+			       vqp->fw ? "fw" : "sw", vqp->mqp.qpn, err);
+		return;
+	}
 	if (!vqp->fw) {
 		mlx5_db_free(ndev->mvdev.mdev, &vqp->db);
 		rq_buf_free(ndev, vqp);
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH v2] vdpa/mlx5: Don't free QP buffers if destroying the QP fails
  2026-11-02 20:47 [PATCH v2] vdpa/mlx5: Don't free QP buffers if destroying the QP fails Yuho Choi
@ 2026-11-02 20:51 ` sashiko-bot
  0 siblings, 0 replies; 2+ messages in thread
From: sashiko-bot @ 2026-11-02 20:51 UTC (permalink / raw)
  To: Yuho Choi; +Cc: virtualization, Michael S. Tsirkin, Eugenio Perez

> qp_destroy() frees the RQ buffer and doorbell record of a driver-owned
> QP even when DESTROY_QP fails. The QP then still exists in firmware and
> can read WQEs and the doorbell record from freed memory.
> 
> Return without freeing them in that case, as cq_destroy() does, and
> include the QP type and the error in the warning.
> 
> Signed-off-by: Yuho Choi <oss.patchbox@gmail.com>

Sashiko has reviewed this patch and found no issues.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261102204734.443140-2-oss.patchbox@gmail.com?part=1


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-11-02 20:51 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-02 20:47 [PATCH v2] vdpa/mlx5: Don't free QP buffers if destroying the QP fails Yuho Choi
2026-11-02 20:51 ` sashiko-bot

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.