[PATCH] DmaBufAllocator: Avoid syncing with an invalid file descriptor

Cheng-Hao Yang chenghaoyang at chromium.org
Mon Jan 13 21:28:25 CET 2025


Hi Milan,


On Mon, Jan 13, 2025 at 7:00 PM Milan Zamazal <mzamazal at redhat.com> wrote:
>
> 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 ... ?

Done

>
> > +     // Avoid syncing with an invalid file descriptor in this case.
>
> I think /* ... */ style comments are to be used in libcamera.

Right, will be updated.

BR,
Harvey

>
> > +     if (!fd_.isValid())
> > +             return;
> > +
> >       struct dma_buf_sync sync = {
> >               .flags = flags_ | step
> >       };
>


More information about the libcamera-devel mailing list