1 From 123507714c5b2fd44d78f2eac3dc8ade39bb3018 Mon Sep 17 00:00:00 2001
2 From: Dave Stevenson <dave.stevenson@raspberrypi.org>
3 Date: Fri, 3 May 2019 13:27:51 +0100
4 Subject: [PATCH 494/703] staging: vchiq-mmal: Fix memory leak of vchiq
7 The vchiq instance was allocated from vchiq_mmal_init via
8 vchi_initialise, but was never released with vchi_disconnect.
10 Retain the handle and release it from vchiq_mmal_finalise.
12 Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.org>
14 drivers/staging/vc04_services/vchiq-mmal/mmal-vchiq.c | 9 +++++++--
15 1 file changed, 7 insertions(+), 2 deletions(-)
17 --- a/drivers/staging/vc04_services/vchiq-mmal/mmal-vchiq.c
18 +++ b/drivers/staging/vc04_services/vchiq-mmal/mmal-vchiq.c
19 @@ -176,6 +176,7 @@ struct mmal_msg_context {
22 struct vchiq_mmal_instance {
23 + VCHI_INSTANCE_T vchi_instance;
24 VCHI_SERVICE_HANDLE_T handle;
26 /* ensure serialised access to service */
27 @@ -1981,7 +1982,7 @@ EXPORT_SYMBOL_GPL(vchiq_mmal_component_i
28 int vchiq_mmal_component_finalise(struct vchiq_mmal_instance *instance,
29 struct vchiq_mmal_component *component)
34 if (mutex_lock_interruptible(&instance->vchiq_mutex))
36 @@ -2094,6 +2095,8 @@ int vchiq_mmal_finalise(struct vchiq_mma
38 idr_destroy(&instance->context_map);
40 + vchi_disconnect(instance->vchi_instance);
45 @@ -2105,7 +2108,7 @@ int vchiq_mmal_init(struct vchiq_mmal_in
47 struct vchiq_mmal_instance *instance;
48 static VCHI_CONNECTION_T *vchi_connection;
49 - static VCHI_INSTANCE_T vchi_instance;
50 + VCHI_INSTANCE_T vchi_instance;
51 SERVICE_CREATION_T params = {
52 .version = VCHI_VERSION_EX(VC_MMAL_VER, VC_MMAL_MIN_VER),
53 .service_id = VC_MMAL_SERVER_NAME,
54 @@ -2151,6 +2154,8 @@ int vchiq_mmal_init(struct vchiq_mmal_in
58 + instance->vchi_instance = vchi_instance;
60 mutex_init(&instance->vchiq_mutex);
62 instance->bulk_scratch = vmalloc(PAGE_SIZE);