From 66071490694f92817ed6b27de425b4a33a51386e Mon Sep 17 00:00:00 2001 From: Yin Tao Date: Thu, 24 Aug 2023 18:26:08 +0800 Subject: [PATCH] rpmsg_virtio: fix rpmsg_service memory leak when stop remote Rpmsg service may malloc memory in the rpmsg bind callback(): rdev->ns_bind_cb() When stop remote, the remote may not send RPMSG_NS_DESTROY message back (baceause the remote may has crashed), so call the unbind callback in rpmsg_deinit_vdev() to aviod potential memroy leak in rpmsg services. Signed-off-by: Yin Tao --- lib/rpmsg/rpmsg_virtio.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/rpmsg/rpmsg_virtio.c b/lib/rpmsg/rpmsg_virtio.c index ea4cc0d9e..53d195c0a 100644 --- a/lib/rpmsg/rpmsg_virtio.c +++ b/lib/rpmsg/rpmsg_virtio.c @@ -862,6 +862,8 @@ void rpmsg_deinit_vdev(struct rpmsg_virtio_device *rvdev) node = rdev->endpoints.next; ept = metal_container_of(node, struct rpmsg_endpoint, node); rpmsg_destroy_ept(ept); + if (ept->ns_unbind_cb) + ept->ns_unbind_cb(ept); } rvdev->rvq = 0;