diff options
author | Gaosheng Cui <cuigaosheng1@huawei.com> | 2024-10-09 16:28:02 +0800 |
---|---|---|
committer | Hans Verkuil <hverkuil-cisco@xs4all.nl> | 2024-10-12 16:28:26 +0200 |
commit | 0f514068fbc5d4d189c817adc7c4e32cffdc2e47 (patch) | |
tree | b3cfdb8cddee71f2c39fcc06024e3dbf4801a926 /drivers/media/platform/allegro-dvt | |
parent | 869f38ae07f7df829da4951c3d1f7a2be09c2e9a (diff) |
media: platform: allegro-dvt: Fix possible memory leak in allocate_buffers_internal()
The buffer in the loop should be released under the exception path,
otherwise there may be a memory leak here.
To mitigate this, free the buffer when allegro_alloc_buffer fails.
Fixes: f20387dfd065 ("media: allegro: add Allegro DVT video IP core driver")
Cc: <stable@vger.kernel.org>
Signed-off-by: Gaosheng Cui <cuigaosheng1@huawei.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Diffstat (limited to 'drivers/media/platform/allegro-dvt')
-rw-r--r-- | drivers/media/platform/allegro-dvt/allegro-core.c | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/drivers/media/platform/allegro-dvt/allegro-core.c b/drivers/media/platform/allegro-dvt/allegro-core.c index 76b4de1150b2..44e0d5512f94 100644 --- a/drivers/media/platform/allegro-dvt/allegro-core.c +++ b/drivers/media/platform/allegro-dvt/allegro-core.c @@ -1509,8 +1509,10 @@ static int allocate_buffers_internal(struct allegro_channel *channel, INIT_LIST_HEAD(&buffer->head); err = allegro_alloc_buffer(dev, buffer, size); - if (err) + if (err) { + kfree(buffer); goto err; + } list_add(&buffer->head, list); } |