Thread (3 messages) flat view 3 messages, 2 authors, 2012-09-10

Re: [PATCH] ext4: fix possible non-initialized variable

From: Carlos Maiolino <hidden>
Date: 2012-09-10 16:36:03

I'm afraid this doesn't fix it.  So now err is init to 0, but then:

        err = ext4_map_blocks(handle, inode, &map,
                              create ? EXT4_GET_BLOCKS_CREATE : 0);

so err is immediately reset to whatever ext4_map_blocks returns, which might be 0.
If so, we don't go down this case:

        if (err < 0)
                *errp = err;

and we do go down this case,

        if (err <= 0)
                return NULL;

in which case we return with *errp unset.

It needs something like this, though maybe this could be made prettier/clearer.

+	*errp = 0;
 	if (err < 0)
 		*errp = err;
 	if (err <= 0)
 		return NULL;
-	*errp = 0;
Agreed. just initializing err variable into ext4_getblk() won't ensure *errp
will be filled with 'err' content. Thanks. I'll wait for some extra inputs and
see if is there anything else people have in mind, then release a v2 patch
-- 
--Carlos
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help