]> git.ipfire.org Git - thirdparty/kernel/linux.git/commit
media: iris: Add buffer to list only after successful allocation
authorDikshita Agarwal <dikshita.agarwal@oss.qualcomm.com>
Mon, 29 Dec 2025 06:31:20 +0000 (12:01 +0530)
committerHans Verkuil <hverkuil+cisco@kernel.org>
Tue, 20 Jan 2026 13:00:12 +0000 (14:00 +0100)
commit2d0bbd982dfdd67da488a772f7a8a1bdca7642bf
tree906ef01c2136ef7d3f6edc346f3f417625b68a00
parentbbef55f414100853d5bcea56a41f8b171bac8fcb
media: iris: Add buffer to list only after successful allocation

Move `list_add_tail()` to after `dma_alloc_attrs()` succeeds when creating
internal buffers. Previously, the buffer was enqueued in `buffers->list`
before the DMA allocation. If the allocation failed, the function returned
`-ENOMEM` while leaving a partially initialized buffer in the list, which
could lead to inconsistent state and potential leaks.

By adding the buffer to the list only after `dma_alloc_attrs()` succeeds,
we ensure the list contains only valid, fully initialized buffers.

Fixes: 73702f45db81 ("media: iris: allocate, initialize and queue internal buffers")
Reviewed-by: Bryan O'Donoghue <bod@kernel.org>
Signed-off-by: Dikshita Agarwal <dikshita.agarwal@oss.qualcomm.com>
Reviewed-by: Vikash Garodia <vikash.garodia@oss.qualcomm.com>
Cc: stable@vger.kernel.org
Signed-off-by: Bryan O'Donoghue <bod@kernel.org>
Signed-off-by: Hans Verkuil <hverkuil+cisco@kernel.org>
drivers/media/platform/qcom/iris/iris_buffer.c