media: platform: allegro-dvt: Fix possible memory leak in allocate_buffers_internal()
commit0f514068fbupstream. 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:f20387dfd0("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> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
committed by
Greg Kroah-Hartman
parent
6ef14ba50a
commit
cf642904be
@@ -1250,8 +1250,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);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user