[PATCH 2/5] rtems-fdt.c: Fix Resource leak (CID #1437645)

Niteesh G. S. niteesh.gs at gmail.com
Tue Mar 16 07:15:22 UTC 2021


On Tue, 16 Mar 2021, 1:37 am Gedare Bloom, <gedare at rtems.org> wrote:

> This one looks ok to me, Niteesh?
>
+1

The below question is not related to this patch.

Out of interest, I started going through the code  and I am a bit confused
in the following statement

https://git.rtems.org/rtems/tree/cpukit/libmisc/rtems-fdt/rtems-fdt.c#n574

This else block is reached when the FDT blob is not compressed, in this
case the size variable is set to the file size since this is raw data.

In the while loop, we are looping on size, but we never modify the size. I
think, line 583 should be
                    size -= r;
Instead of
                    r -= size;
Is this a bug??
Or am I missing something?

PS: I am really sorry, If the formatting looks off I wrote this mail using
my mobile.

Thanks
Niteesh


> On Fri, Mar 12, 2021 at 8:19 AM Ryan Long <ryan.long at oarcorp.com> wrote:
> >
> > CID 1437645: Resource leak in rtems_fdt_load().
> >
> > Closes #4297
> > ---
> >  cpukit/libmisc/rtems-fdt/rtems-fdt.c | 1 +
> >  1 file changed, 1 insertion(+)
> >
> > diff --git a/cpukit/libmisc/rtems-fdt/rtems-fdt.c
> b/cpukit/libmisc/rtems-fdt/rtems-fdt.c
> > index 0ea3653..5bb7ce0 100644
> > --- a/cpukit/libmisc/rtems-fdt/rtems-fdt.c
> > +++ b/cpukit/libmisc/rtems-fdt/rtems-fdt.c
> > @@ -611,6 +611,7 @@ rtems_fdt_load (const char* filename,
> rtems_fdt_handle* handle)
> >      return fe;
> >    }
> >
> > +  close (bf);
> >    return 0;
> >  }
> >
> > --
> > 1.8.3.1
> >
> > _______________________________________________
> > devel mailing list
> > devel at rtems.org
> > http://lists.rtems.org/mailman/listinfo/devel
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.rtems.org/pipermail/devel/attachments/20210316/2d615683/attachment-0001.html>


More information about the devel mailing list