[PATCH] raspberrypi: vchiq: free recycle buffer on thread exit

From: Yousef Alhouseen

Date: Mon Jun 29 2026 - 12:25:22 EST


recycle_func() allocates a bitmap used while processing the free queue,
but returns directly when remote_event_wait() fails. The normal
kthread-stop path also exits without releasing the allocation.

Break out of the loop on wait errors, free the bitmap, and return the
saved status so both the error and stop paths release the per-thread
buffer.

Signed-off-by: Yousef Alhouseen <alhouseenyousef@xxxxxxxxx>
---
drivers/platform/raspberrypi/vchiq-interface/vchiq_core.c | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/drivers/platform/raspberrypi/vchiq-interface/vchiq_core.c b/drivers/platform/raspberrypi/vchiq-interface/vchiq_core.c
index 48d6b1d74329..f8b2d4b1a30e 100644
--- a/drivers/platform/raspberrypi/vchiq-interface/vchiq_core.c
+++ b/drivers/platform/raspberrypi/vchiq-interface/vchiq_core.c
@@ -2346,7 +2346,7 @@ recycle_func(void *v)
struct vchiq_shared_state *local = state->local;
u32 *found;
size_t length;
- int ret;
+ int ret = 0;

length = sizeof(*found) * BITSET_SIZE(VCHIQ_MAX_SERVICES);

@@ -2358,11 +2358,12 @@ recycle_func(void *v)
while (!kthread_should_stop()) {
ret = remote_event_wait(&state->recycle_event, &local->recycle);
if (ret)
- return ret;
+ break;

process_free_queue(state, found, length);
}
- return 0;
+ kfree(found);
+ return ret;
}

/* Called by the sync thread */
--
2.54.0