]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
media: videobuf2-core: clear memory related fields in __vb2_plane_dmabuf_put()
authorYunke Cao <yunkec@chromium.org>
Wed, 14 Aug 2024 02:06:40 +0000 (11:06 +0900)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 17 Oct 2024 13:11:51 +0000 (15:11 +0200)
[ Upstream commit 6a9c97ab6b7e85697e0b74e86062192a5ffffd99 ]

Clear vb2_plane's memory related fields in __vb2_plane_dmabuf_put(),
including bytesused, length, fd and data_offset.

Remove the duplicated code in __prepare_dmabuf().

Signed-off-by: Yunke Cao <yunkec@chromium.org>
Acked-by: Tomasz Figa <tfiga@chromium.org>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/media/common/videobuf2/videobuf2-core.c

index 30c8497f7c118f68404b982c1a621d3a9972f0be..b66e80e6924e5b6450531dc00d1a55c27d6086a3 100644 (file)
@@ -302,6 +302,10 @@ static void __vb2_plane_dmabuf_put(struct vb2_buffer *vb, struct vb2_plane *p)
        p->mem_priv = NULL;
        p->dbuf = NULL;
        p->dbuf_mapped = 0;
+       p->bytesused = 0;
+       p->length = 0;
+       p->m.fd = 0;
+       p->data_offset = 0;
 }
 
 /*
@@ -1280,10 +1284,6 @@ static int __prepare_dmabuf(struct vb2_buffer *vb)
 
                /* Release previously acquired memory if present */
                __vb2_plane_dmabuf_put(vb, &vb->planes[plane]);
-               vb->planes[plane].bytesused = 0;
-               vb->planes[plane].length = 0;
-               vb->planes[plane].m.fd = 0;
-               vb->planes[plane].data_offset = 0;
 
                /* Acquire each plane's memory */
                mem_priv = call_ptr_memop(attach_dmabuf,