Skip to content

Commit 0f51406

Browse files
gscuiHans Verkuil
authored andcommitted
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: f20387d ("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>
1 parent 869f38a commit 0f51406

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

drivers/media/platform/allegro-dvt/allegro-core.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1509,8 +1509,10 @@ static int allocate_buffers_internal(struct allegro_channel *channel,
15091509
INIT_LIST_HEAD(&buffer->head);
15101510

15111511
err = allegro_alloc_buffer(dev, buffer, size);
1512-
if (err)
1512+
if (err) {
1513+
kfree(buffer);
15131514
goto err;
1515+
}
15141516
list_add(&buffer->head, list);
15151517
}
15161518

0 commit comments

Comments
 (0)