1
0
Fork 0
mirror of https://git.openwrt.org/openwrt/openwrt.git synced 2024-05-19 14:06:29 +02:00
openwrt/target/linux/bcm27xx/patches-6.1/950-0173-staging-mmal-vchiq...
Hauke Mehrtens 1a44a260fe kernel: bump 6.1 to 6.1.84
Removed upstreamed:
   pistachio/patches-6.1/110-pwm-img-fix-clock-lookup.patch [1]

All other patches automatically rebased.

1. https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?h=v6.1.84&id=44b6fb6cdedb2c391a2da355521d4610b2645fcc

Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
2024-04-14 18:03:37 +02:00

77 lines
2.4 KiB
Diff

From 36fa884a872037d03ea7449922665f16056ae94d Mon Sep 17 00:00:00 2001
From: Dave Stevenson <dave.stevenson@raspberrypi.org>
Date: Thu, 2 May 2019 15:50:01 +0100
Subject: [PATCH] staging: mmal-vchiq: Fix memory leak in error path
On error, vchiq_mmal_component_init could leave the
event context allocated for ports.
Clean them up in the error path.
Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.org>
---
.../vc04_services/vchiq-mmal/mmal-vchiq.c | 29 +++++++++++++------
1 file changed, 20 insertions(+), 9 deletions(-)
--- a/drivers/staging/vc04_services/vchiq-mmal/mmal-vchiq.c
+++ b/drivers/staging/vc04_services/vchiq-mmal/mmal-vchiq.c
@@ -1766,9 +1766,26 @@ static void free_event_context(struct vc
{
struct mmal_msg_context *ctx = port->event_context;
+ if (!ctx)
+ return;
+
kfree(ctx->u.bulk.buffer->buffer);
kfree(ctx->u.bulk.buffer);
release_msg_context(ctx);
+ port->event_context = NULL;
+}
+
+static void release_all_event_contexts(struct vchiq_mmal_component *component)
+{
+ int idx;
+
+ for (idx = 0; idx < component->inputs; idx++)
+ free_event_context(&component->input[idx]);
+ for (idx = 0; idx < component->outputs; idx++)
+ free_event_context(&component->output[idx]);
+ for (idx = 0; idx < component->clocks; idx++)
+ free_event_context(&component->clock[idx]);
+ free_event_context(&component->control);
}
/* Initialise a mmal component and its ports
@@ -1866,6 +1883,7 @@ int vchiq_mmal_component_init(struct vch
release_component:
destroy_component(instance, component);
+ release_all_event_contexts(component);
unlock:
if (component)
component->in_use = 0;
@@ -1881,7 +1899,7 @@ EXPORT_SYMBOL_GPL(vchiq_mmal_component_i
int vchiq_mmal_component_finalise(struct vchiq_mmal_instance *instance,
struct vchiq_mmal_component *component)
{
- int ret, idx;
+ int ret;
if (mutex_lock_interruptible(&instance->vchiq_mutex))
return -EINTR;
@@ -1893,14 +1911,7 @@ int vchiq_mmal_component_finalise(struct
component->in_use = 0;
- for (idx = 0; idx < component->inputs; idx++)
- free_event_context(&component->input[idx]);
- for (idx = 0; idx < component->outputs; idx++)
- free_event_context(&component->output[idx]);
- for (idx = 0; idx < component->clocks; idx++)
- free_event_context(&component->clock[idx]);
-
- free_event_context(&component->control);
+ release_all_event_contexts(component);
mutex_unlock(&instance->vchiq_mutex);