[PATCH 2/5] rtems-fdt.c: Fix Resource leak (CID #1437645)
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@rtems.org http://lists.rtems.org/mailman/listinfo/devel
Re: [PATCH 2/5] rtems-fdt.c: Fix Resource leak (CID #1437645)
This one looks ok to me, Niteesh? On Fri, Mar 12, 2021 at 8:19 AM Ryan Long 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@rtems.org > http://lists.rtems.org/mailman/listinfo/devel ___ devel mailing list devel@rtems.org http://lists.rtems.org/mailman/listinfo/devel
Re: [PATCH 2/5] rtems-fdt.c: Fix Resource leak (CID #1437645)
On Tue, 16 Mar 2021, 1:37 am Gedare Bloom, 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 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@rtems.org > > http://lists.rtems.org/mailman/listinfo/devel > ___ devel mailing list devel@rtems.org http://lists.rtems.org/mailman/listinfo/devel
Re: [PATCH 2/5] rtems-fdt.c: Fix Resource leak (CID #1437645)
On Tue, Mar 16, 2021 at 1:15 AM Niteesh G. S. wrote: > > > > On Tue, 16 Mar 2021, 1:37 am Gedare Bloom, 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? > it looks weird to me too. Chris? > 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 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@rtems.org >> > http://lists.rtems.org/mailman/listinfo/devel ___ devel mailing list devel@rtems.org http://lists.rtems.org/mailman/listinfo/devel
Re: [PATCH 2/5] rtems-fdt.c: Fix Resource leak (CID #1437645)
On 17/3/21 2:14 am, Gedare Bloom wrote: > On Tue, Mar 16, 2021 at 1:15 AM Niteesh G. S. wrote: >> On Tue, 16 Mar 2021, 1:37 am Gedare Bloom, 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? >> > > it looks weird to me too. Chris? > That is a bug. Nice find. The use case for this call has an FPGA bitfile and the compressed FDT file in a single package. Thanks Chris ___ devel mailing list devel@rtems.org http://lists.rtems.org/mailman/listinfo/devel
Re: [PATCH 2/5] rtems-fdt.c: Fix Resource leak (CID #1437645)
On Thu, Mar 18, 2021 at 1:01 AM Chris Johns wrote: > I do not know. Maybe ask or post a patch? > I have sent a patch please take a look at it https://lists.rtems.org/pipermail/devel/2021-March/065610.html > > On 18 Mar 2021, at 2:14 am, Niteesh G. S. wrote: > > > > > On Wed, 17 Mar 2021, 12:04 am Chris Johns, wrote: > >> On 17/3/21 2:14 am, Gedare Bloom wrote: >> > On Tue, Mar 16, 2021 at 1:15 AM Niteesh G. S. >> wrote: >> >> On Tue, 16 Mar 2021, 1:37 am Gedare Bloom, 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? >> >> >> > >> > it looks weird to me too. Chris? >> > >> >> That is a bug. Nice find. >> > Is someone working on a patch for this? If not I'll send one. > > Thanks, > Niteesh. > > >> The use case for this call has an FPGA bitfile and the compressed FDT >> file in a >> single package. >> >> Thanks >> Chris >> >> ___ devel mailing list devel@rtems.org http://lists.rtems.org/mailman/listinfo/devel