mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] vdpa/mlx5: fix wrong list iterated in add_direct_chain error path
@ 2026-07-01 11:36 lirongqing
  2026-07-01 13:44 ` Eugenio Perez Martin
  2026-07-01 15:02 ` Dragos Tatulea
  0 siblings, 2 replies; 3+ messages in thread
From: lirongqing @ 2026-07-01 11:36 UTC (permalink / raw)
  To: Dragos Tatulea, Michael S . Tsirkin, Jason Wang, Xuan Zhuo,
	Eugenio Pérez, Kees Cook, Rosen Penev, Parav Pandit,
	Eli Cohen, virtualization, linux-kernel
  Cc: Li RongQing

From: Li RongQing <lirongqing@baidu.com>

In add_direct_chain(), newly allocated direct MR entries are added to
the local list 'tmp', which is spliced into mr->head only on success.
On the error path, the cleanup loop was incorrectly iterating over
mr->head instead of tmp.

Fix by iterating over 'tmp' in the err_alloc cleanup path.

Fixes: 94abbccdf291 ("vdpa/mlx5: Add shared memory registration code")
Signed-off-by: Li RongQing <lirongqing@baidu.com>
---
 drivers/vdpa/mlx5/core/mr.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/vdpa/mlx5/core/mr.c b/drivers/vdpa/mlx5/core/mr.c
index 6d02ccf..1a224f0 100644
--- a/drivers/vdpa/mlx5/core/mr.c
+++ b/drivers/vdpa/mlx5/core/mr.c
@@ -480,7 +480,7 @@ static int add_direct_chain(struct mlx5_vdpa_dev *mvdev,
 	return 0;
 
 err_alloc:
-	list_for_each_entry_safe(dmr, n, &mr->head, list) {
+	list_for_each_entry_safe(dmr, n, &tmp, list) {
 		list_del_init(&dmr->list);
 		unmap_direct_mr(mvdev, dmr);
 		kfree(dmr);
-- 
2.9.4


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

end of thread, other threads:[~2026-07-01 15:02 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-07-01 11:36 [PATCH] vdpa/mlx5: fix wrong list iterated in add_direct_chain error path lirongqing
2026-07-01 13:44 ` Eugenio Perez Martin
2026-07-01 15:02 ` Dragos Tatulea

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®