All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] Initialize local relocator subchunk struct to all zeros
@ 2022-07-14 13:41 Ross Philipson
  2022-07-14 14:38 ` Darren Kenny
  0 siblings, 1 reply; 4+ messages in thread
From: Ross Philipson @ 2022-07-14 13:41 UTC (permalink / raw)
  To: grub-devel
  Cc: daniel.kiper, ross.philipson, alec.r.brown, darren.kenny, jag.raman

The way the code is written the tofree variable would never be
passed to the free_subchunk() function uninitialized. Coverity
cannot determine this and flags the situation as "Using uninitialized
value...". The fix is just to initialize the local struct.

Fixes: CID 314016

Signed-off-by: Ross Philipson <ross.philipson@oracle.com>
---
 grub-core/lib/relocator.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/grub-core/lib/relocator.c b/grub-core/lib/relocator.c
index 68ef128..bfcc70d 100644
--- a/grub-core/lib/relocator.c
+++ b/grub-core/lib/relocator.c
@@ -989,7 +989,7 @@ malloc_in_range (struct grub_relocator *rel,
 	if (j != 0 && events[j - 1].pos != events[j].pos)
 	  {
 	    grub_addr_t alloc_start, alloc_end;
-	    struct grub_relocator_subchunk tofree;
+	    struct grub_relocator_subchunk tofree = {0};
 	    struct grub_relocator_subchunk *curschu = &tofree;
 	    if (!oom)
 	      curschu = &res->subchunks[cural];
-- 
1.8.3.1



^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] Initialize local relocator subchunk struct to all zeros
  2022-07-14 13:41 [PATCH] Initialize local relocator subchunk struct to all zeros Ross Philipson
@ 2022-07-14 14:38 ` Darren Kenny
  2022-07-15 21:21   ` Alec Brown
  0 siblings, 1 reply; 4+ messages in thread
From: Darren Kenny @ 2022-07-14 14:38 UTC (permalink / raw)
  To: Ross Philipson, grub-devel
  Cc: daniel.kiper, ross.philipson, alec.r.brown, jag.raman

Hi Ross,

This looks good to me.

On Thursday, 2022-07-14 at 09:41:28 -04, Ross Philipson wrote:
> The way the code is written the tofree variable would never be
> passed to the free_subchunk() function uninitialized. Coverity
> cannot determine this and flags the situation as "Using uninitialized
> value...". The fix is just to initialize the local struct.
>
> Fixes: CID 314016
>
> Signed-off-by: Ross Philipson <ross.philipson@oracle.com>

Reviewed-by: Darren Kenny <darren.kenny@oracle.com>

Thanks,

Darren.

> ---
>  grub-core/lib/relocator.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/grub-core/lib/relocator.c b/grub-core/lib/relocator.c
> index 68ef128..bfcc70d 100644
> --- a/grub-core/lib/relocator.c
> +++ b/grub-core/lib/relocator.c
> @@ -989,7 +989,7 @@ malloc_in_range (struct grub_relocator *rel,
>  	if (j != 0 && events[j - 1].pos != events[j].pos)
>  	  {
>  	    grub_addr_t alloc_start, alloc_end;
> -	    struct grub_relocator_subchunk tofree;
> +	    struct grub_relocator_subchunk tofree = {0};
>  	    struct grub_relocator_subchunk *curschu = &tofree;
>  	    if (!oom)
>  	      curschu = &res->subchunks[cural];
> -- 
> 1.8.3.1


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] Initialize local relocator subchunk struct to all zeros
  2022-07-14 14:38 ` Darren Kenny
@ 2022-07-15 21:21   ` Alec Brown
  2022-07-19 12:01     ` Daniel Kiper
  0 siblings, 1 reply; 4+ messages in thread
From: Alec Brown @ 2022-07-15 21:21 UTC (permalink / raw)
  To: Darren Kenny; +Cc: Ross Philipson, grub-devel, daniel.kiper, jag.raman

On Thu, Jul 14, 2022 at 03:38:04PM +0100, Darren Kenny wrote:
> Hi Ross,
> 
> This looks good to me.
> 
> On Thursday, 2022-07-14 at 09:41:28 -04, Ross Philipson wrote:
> > The way the code is written the tofree variable would never be
> > passed to the free_subchunk() function uninitialized. Coverity
> > cannot determine this and flags the situation as "Using uninitialized
> > value...". The fix is just to initialize the local struct.
> >
> > Fixes: CID 314016
> >
> > Signed-off-by: Ross Philipson <ross.philipson@oracle.com>
> 
> Reviewed-by: Darren Kenny <darren.kenny@oracle.com>

I ran this through a private Coverity scan which marked the bug as eliminated
and didn't have any issues running it on a VM.

Tested-by: Alec Brown <alec.r.brown@oracle.com>

Alec Brown

> 
> Thanks,
> 
> Darren.
> 
> > ---
> >  grub-core/lib/relocator.c | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/grub-core/lib/relocator.c b/grub-core/lib/relocator.c
> > index 68ef128..bfcc70d 100644
> > --- a/grub-core/lib/relocator.c
> > +++ b/grub-core/lib/relocator.c
> > @@ -989,7 +989,7 @@ malloc_in_range (struct grub_relocator *rel,
> >  	if (j != 0 && events[j - 1].pos != events[j].pos)
> >  	  {
> >  	    grub_addr_t alloc_start, alloc_end;
> > -	    struct grub_relocator_subchunk tofree;
> > +	    struct grub_relocator_subchunk tofree = {0};
> >  	    struct grub_relocator_subchunk *curschu = &tofree;
> >  	    if (!oom)
> >  	      curschu = &res->subchunks[cural];
> > -- 
> > 1.8.3.1


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] Initialize local relocator subchunk struct to all zeros
  2022-07-15 21:21   ` Alec Brown
@ 2022-07-19 12:01     ` Daniel Kiper
  0 siblings, 0 replies; 4+ messages in thread
From: Daniel Kiper @ 2022-07-19 12:01 UTC (permalink / raw)
  To: Alec Brown; +Cc: Darren Kenny, Ross Philipson, grub-devel, jag.raman

On Fri, Jul 15, 2022 at 05:21:21PM -0400, Alec Brown wrote:
> On Thu, Jul 14, 2022 at 03:38:04PM +0100, Darren Kenny wrote:
> > Hi Ross,
> >
> > This looks good to me.
> >
> > On Thursday, 2022-07-14 at 09:41:28 -04, Ross Philipson wrote:
> > > The way the code is written the tofree variable would never be
> > > passed to the free_subchunk() function uninitialized. Coverity
> > > cannot determine this and flags the situation as "Using uninitialized
> > > value...". The fix is just to initialize the local struct.
> > >
> > > Fixes: CID 314016
> > >
> > > Signed-off-by: Ross Philipson <ross.philipson@oracle.com>
> >
> > Reviewed-by: Darren Kenny <darren.kenny@oracle.com>
>
> I ran this through a private Coverity scan which marked the bug as eliminated
> and didn't have any issues running it on a VM.
>
> Tested-by: Alec Brown <alec.r.brown@oracle.com>

Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>

Daniel


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2022-07-19 12:01 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-07-14 13:41 [PATCH] Initialize local relocator subchunk struct to all zeros Ross Philipson
2022-07-14 14:38 ` Darren Kenny
2022-07-15 21:21   ` Alec Brown
2022-07-19 12:01     ` Daniel Kiper

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.