Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Gaosheng Cui and committed by
Hans Verkuil
0f514068 869f38ae

+3 -1
+3 -1
drivers/media/platform/allegro-dvt/allegro-core.c
··· 1509 1509 INIT_LIST_HEAD(&buffer->head); 1510 1510 1511 1511 err = allegro_alloc_buffer(dev, buffer, size); 1512 - if (err) 1512 + if (err) { 1513 + kfree(buffer); 1513 1514 goto err; 1515 + } 1514 1516 list_add(&buffer->head, list); 1515 1517 } 1516 1518