* [PATCH 2.6.15-rc7] udf/balloc.c : Fix use of uninitialized data
@ 2005-12-28 17:13 Parag Warudkar
2005-12-28 17:37 ` Parag Warudkar
2005-12-28 18:47 ` Al Viro
0 siblings, 2 replies; 3+ messages in thread
From: Parag Warudkar @ 2005-12-28 17:13 UTC (permalink / raw)
To: linux-kernel
[-- Attachment #1: Type: text/plain, Size: 1212 bytes --]
2.6.15-rc7 - GCC warns correctly -
fs/udf/balloc.c: In function 'udf_table_new_block':
fs/udf/balloc.c:757: warning: 'goal_eloc.logicalBlockNum' may be used
uninitialized in this function
Variable goal_eloc is automatic, non-static and initialized conditionally -
if (nspread < spread)
{
...........
goal_eloc = eloc;
...........
}
The following patch fixes this by initializing the goal_eloc variable to zero.
Hopefully zero should be better than some random data! (Patch also
attached in case of problem with below inline version.) Compile
tested.
--- linux-2.6/fs/udf/balloc.c.orig 2005-12-28 11:53:12.000000000 -0500
+++ linux-2.6/fs/udf/balloc.c 2005-12-28 11:53:19.000000000 -0500
@@ -754,7 +754,8 @@ static int udf_table_new_block(struct su
uint32_t spread = 0xFFFFFFFF, nspread = 0xFFFFFFFF;
uint32_t newblock = 0, adsize;
uint32_t extoffset, goal_extoffset, elen, goal_elen = 0;
- kernel_lb_addr bloc, goal_bloc, eloc, goal_eloc;
+ kernel_lb_addr bloc, goal_bloc, eloc,
+ goal_eloc = { .logicalBlockNum=0, .partitionReferenceNum=0 } ;
struct buffer_head *bh, *goal_bh;
int8_t etype;
[-- Attachment #2: patch --]
[-- Type: application/octet-stream, Size: 555 bytes --]
--- linux-2.6/fs/udf/balloc.c.orig 2005-12-28 11:53:12.000000000 -0500
+++ linux-2.6/fs/udf/balloc.c 2005-12-28 11:53:19.000000000 -0500
@@ -754,7 +754,8 @@ static int udf_table_new_block(struct su
uint32_t spread = 0xFFFFFFFF, nspread = 0xFFFFFFFF;
uint32_t newblock = 0, adsize;
uint32_t extoffset, goal_extoffset, elen, goal_elen = 0;
- kernel_lb_addr bloc, goal_bloc, eloc, goal_eloc;
+ kernel_lb_addr bloc, goal_bloc, eloc,
+ goal_eloc = { .logicalBlockNum=0, .partitionReferenceNum=0 } ;
struct buffer_head *bh, *goal_bh;
int8_t etype;
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH 2.6.15-rc7] udf/balloc.c : Fix use of uninitialized data
2005-12-28 17:13 [PATCH 2.6.15-rc7] udf/balloc.c : Fix use of uninitialized data Parag Warudkar
@ 2005-12-28 17:37 ` Parag Warudkar
2005-12-28 18:47 ` Al Viro
1 sibling, 0 replies; 3+ messages in thread
From: Parag Warudkar @ 2005-12-28 17:37 UTC (permalink / raw)
To: linux-kernel; +Cc: akpm
Forgot to add Signed-off-by - corrected patch follows -
Signed-off-by: Parag Warudkar <parag.warudkar@gmail.com>
Variable goal_eloc is automatic, non-static and initialized conditionally.
The following patch fixes this by initializing the goal_eloc variable to zero.
Hopefully zero should be better than some random data! (Patch also
attached in case of problem with below inline version.) Compile
tested.
--- linux-2.6/fs/udf/balloc.c.orig 2005-12-28 11:53:12.000000000 -0500
+++ linux-2.6/fs/udf/balloc.c 2005-12-28 11:53:19.000000000 -0500
@@ -754,7 +754,8 @@ static int udf_table_new_block(struct su
uint32_t spread = 0xFFFFFFFF, nspread = 0xFFFFFFFF;
uint32_t newblock = 0, adsize;
uint32_t extoffset, goal_extoffset, elen, goal_elen = 0;
- kernel_lb_addr bloc, goal_bloc, eloc, goal_eloc;
+ kernel_lb_addr bloc, goal_bloc, eloc,
+ goal_eloc = { .logicalBlockNum=0, .partitionReferenceNum=0 } ;
struct buffer_head *bh, *goal_bh;
int8_t etype;
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH 2.6.15-rc7] udf/balloc.c : Fix use of uninitialized data
2005-12-28 17:13 [PATCH 2.6.15-rc7] udf/balloc.c : Fix use of uninitialized data Parag Warudkar
2005-12-28 17:37 ` Parag Warudkar
@ 2005-12-28 18:47 ` Al Viro
1 sibling, 0 replies; 3+ messages in thread
From: Al Viro @ 2005-12-28 18:47 UTC (permalink / raw)
To: Parag Warudkar; +Cc: linux-kernel
On Wed, Dec 28, 2005 at 12:13:37PM -0500, Parag Warudkar wrote:
> 2.6.15-rc7 - GCC warns correctly -
> fs/udf/balloc.c: In function 'udf_table_new_block':
> fs/udf/balloc.c:757: warning: 'goal_eloc.logicalBlockNum' may be used
> uninitialized in this function
>
> Variable goal_eloc is automatic, non-static and initialized conditionally -
>
> if (nspread < spread)
> {
> ...........
> goal_eloc = eloc;
> ...........
> }
>
> The following patch fixes this by initializing the goal_eloc variable to zero.
> Hopefully zero should be better than some random data!
Wrong. RTFS, please. They have
spread = 0xffffffff;
while (....) {
...
if (nspread < spread) {
spread = nspread;
...
goal_eloc = eloc;
...
}
...
}
...
if (spread == 0xffffffff) {
...
return 0;
}
....
use goal_eloc
which is absolutely correct - to reach the use of goal_eloc we have to
have passed through reassignment of spread between spread = 0xffffffff
and departure via if (spread == 0xffffffff). Such reassignment could
happen only in one block and in the same block we have assignment to
goal_eloc.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2005-12-28 18:47 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-12-28 17:13 [PATCH 2.6.15-rc7] udf/balloc.c : Fix use of uninitialized data Parag Warudkar
2005-12-28 17:37 ` Parag Warudkar
2005-12-28 18:47 ` Al Viro
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox