7c9ac226109fb40dfd399e0eb183b9832d5ab17d
[openwrt/staging/yousong.git] /
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
5 instance
6
7 The vchiq instance was allocated from vchiq_mmal_init via
8 vchi_initialise, but was never released with vchi_disconnect.
9
10 Retain the handle and release it from vchiq_mmal_finalise.
11
12 Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.org>
13 ---
14 drivers/staging/vc04_services/vchiq-mmal/mmal-vchiq.c | 9 +++++++--
15 1 file changed, 7 insertions(+), 2 deletions(-)
16
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 {
20 };
21
22 struct vchiq_mmal_instance {
23 + VCHI_INSTANCE_T vchi_instance;
24 VCHI_SERVICE_HANDLE_T handle;
25
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)
30 {
31 - int ret, idx;
32 + int ret;
33
34 if (mutex_lock_interruptible(&instance->vchiq_mutex))
35 return -EINTR;
36 @@ -2094,6 +2095,8 @@ int vchiq_mmal_finalise(struct vchiq_mma
37
38 idr_destroy(&instance->context_map);
39
40 + vchi_disconnect(instance->vchi_instance);
41 +
42 kfree(instance);
43
44 return status;
45 @@ -2105,7 +2108,7 @@ int vchiq_mmal_init(struct vchiq_mmal_in
46 int status;
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
55 if (!instance)
56 return -ENOMEM;
57
58 + instance->vchi_instance = vchi_instance;
59 +
60 mutex_init(&instance->vchiq_mutex);
61
62 instance->bulk_scratch = vmalloc(PAGE_SIZE);