Initialize local relocator subchunk struct to all zeros
PATCH 1/1 Initialize local relocator subchunk struct to all zeros
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.
--- grub-core/lib/relocator.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
grub-core/lib/relocator.c +1 -1
@@ -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];
Signature · 1 line
1.8.3.1
Hi Ross,
This looks good to me.
Quoted 8 lines · Ross Philipson
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 314016Signed-off-by Ross Philipson <[email protected]>
Thanks,
Darren.
Quoted 19 lines
--- grub-core/lib/relocator.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)grub-core/lib/relocator.c +1
-1@@ -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];Signature · 1 line
1.8.3.1
Alec Brown
Tested-byQuoted 10 lines · Darren Kenny
Hi Ross,
This looks good to me.
Quoted 5 lines · Ross Philipson
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.
Quoted 5 lines
Quoted 3 lines
Fixes CID 314016Signed-off-by Ross Philipson <[email protected]>Reviewed-by Darren Kenny <[email protected]>
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.
Alec Brown
Quoted 24 lines
Thanks,
Darren.
Quoted 19 lines
--- grub-core/lib/relocator.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)grub-core/lib/relocator.c +1
-1@@ -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];Signature · 1 line
1.8.3.1
Daniel Kiper
Reviewed-byQuoted 13 lines · Alec Brown
Quoted 12 lines · Darren Kenny
Hi Ross,
This looks good to me.
Quoted 7 lines · Ross Philipson
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
Quoted 8 lines
Quoted 3 lines
Quoted 1 line
Signed-off-by Ross Philipson <[email protected]>Reviewed-by Darren Kenny <[email protected]>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 <[email protected]>
Daniel