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

[media] media: vb2: correct queue initialization order

q->memory entry is initialized to late, so if allocation of memory buffers
fails, the buffers might not be freed correctly (q->memory is tested in
__vb2_free_mem, which can be called before setting q->memory).

Reported-by: Kamil Debski <k.debski@samsung.com>
Signed-off-by: Marek Szyprowski <m.szyprowski@samsung.com>
Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
CC: Pawel Osciak <pawel@osciak.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>

authored by

Marek Szyprowski and committed by
Mauro Carvalho Chehab
13b14095 ea42c8ec

+1 -2
+1 -2
drivers/media/video/videobuf2-core.c
··· 525 525 num_buffers = min_t(unsigned int, req->count, VIDEO_MAX_FRAME); 526 526 memset(plane_sizes, 0, sizeof(plane_sizes)); 527 527 memset(q->alloc_ctx, 0, sizeof(q->alloc_ctx)); 528 + q->memory = req->memory; 528 529 529 530 /* 530 531 * Ask the driver how many buffers and planes per buffer it requires. ··· 566 565 */ 567 566 ret = num_buffers; 568 567 } 569 - 570 - q->memory = req->memory; 571 568 572 569 /* 573 570 * Return the number of successfully allocated buffers