Skip to content
/ linux Public
forked from torvalds/linux

Commit

Permalink
media: platform: allegro-dvt: Fix possible memory leak in allocate_bu…
Browse files Browse the repository at this point in the history
…ffers_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: <[email protected]>
Signed-off-by: Gaosheng Cui <[email protected]>
Signed-off-by: Hans Verkuil <[email protected]>
  • Loading branch information
gscui authored and Hans Verkuil committed Oct 12, 2024
1 parent 869f38a commit 0f51406
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion drivers/media/platform/allegro-dvt/allegro-core.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down

0 comments on commit 0f51406

Please sign in to comment.