[PATCH] DmaBufAllocator: Avoid syncing with an invalid file descriptor
Milan Zamazal
mzamazal at redhat.com
Mon Jan 13 18:59:57 CET 2025
Hi Harvey,
thank you for the patch.
Harvey Yang <chenghaoyang at chromium.org> writes:
> As DmaSyncer disables the copy c'tor, the move c'tor will be used
> instead. This leaves some DmaSyncers with invalid SharedFDs. They should
> avoid syncing with invalid file descriptors in the d'tor.
>
> Fixes: 545046a41e17 ("DmaBufAllocator: Make DmaSyncer non-copyable")
> Signed-off-by: Harvey Yang <chenghaoyang at chromium.org>
Tested-by: Milan Zamazal <mzamazal at redhat.com>
> ---
> src/libcamera/dma_buf_allocator.cpp | 5 +++++
> 1 file changed, 5 insertions(+)
>
> diff --git a/src/libcamera/dma_buf_allocator.cpp b/src/libcamera/dma_buf_allocator.cpp
> index a014c3b4263c..17a888efaa40 100644
> --- a/src/libcamera/dma_buf_allocator.cpp
> +++ b/src/libcamera/dma_buf_allocator.cpp
> @@ -330,6 +330,11 @@ DmaSyncer::~DmaSyncer()
>
> void DmaSyncer::sync(uint64_t step)
> {
> + // DmaSyncer might be moved and left an empty SharedFD.
... left with an ... ?
> + // Avoid syncing with an invalid file descriptor in this case.
I think /* ... */ style comments are to be used in libcamera.
> + if (!fd_.isValid())
> + return;
> +
> struct dma_buf_sync sync = {
> .flags = flags_ | step
> };
More information about the libcamera-devel
mailing list