From 69292a8e40f4dae8af5f04724e06392cdf03c09e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Eugenio=20P=C3=A9rez?= Date: Tue, 23 Aug 2022 20:20:04 +0200 Subject: util: accept iova_tree_remove_parameter by value MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit It's convenient to call iova_tree_remove from a map returned from iova_tree_find or iova_tree_find_iova. With the current code this is not possible, since we will free it, and then we will try to search for it again. Fix it making accepting the map by value, forcing a copy of the argument. Not applying a fixes tag, since there is no use like that at the moment. Signed-off-by: Eugenio PĂ©rez Signed-off-by: Jason Wang --- net/vhost-vdpa.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'net') diff --git a/net/vhost-vdpa.c b/net/vhost-vdpa.c index 303447a68e..a49e7e649d 100644 --- a/net/vhost-vdpa.c +++ b/net/vhost-vdpa.c @@ -244,7 +244,7 @@ static void vhost_vdpa_cvq_unmap_buf(struct vhost_vdpa *v, void *addr) error_report("Device cannot unmap: %s(%d)", g_strerror(r), r); } - vhost_iova_tree_remove(tree, map); + vhost_iova_tree_remove(tree, *map); } static size_t vhost_vdpa_net_cvq_cmd_len(void) @@ -297,7 +297,7 @@ static bool vhost_vdpa_cvq_map_buf(struct vhost_vdpa *v, return true; dma_map_err: - vhost_iova_tree_remove(v->iova_tree, &map); + vhost_iova_tree_remove(v->iova_tree, map); return false; } -- cgit v1.2.3