diff mbox

[1/2] ocfs2: fix uninitialized variable access

Message ID 1419486737-16102-1-git-send-email-junxiao.bi@oracle.com (mailing list archive)
State New, archived
Headers show

Commit Message

Junxiao Bi Dec. 25, 2014, 5:52 a.m. UTC
Variable "why" is not yet initialized at line 615, fix it.

Signed-off-by: Junxiao Bi <junxiao.bi@oracle.com>
---
 fs/ocfs2/file.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Andrew Morton Jan. 7, 2015, 12:09 a.m. UTC | #1
On Thu, 25 Dec 2014 13:52:16 +0800 Junxiao Bi <junxiao.bi@oracle.com> wrote:

> Variable "why" is not yet initialized at line 615, fix it.
> 
> ...
>
> --- a/fs/ocfs2/file.c
> +++ b/fs/ocfs2/file.c
> @@ -569,7 +569,7 @@ static int __ocfs2_extend_allocation(struct inode *inode, u32 logical_start,
>  	handle_t *handle = NULL;
>  	struct ocfs2_alloc_context *data_ac = NULL;
>  	struct ocfs2_alloc_context *meta_ac = NULL;
> -	enum ocfs2_alloc_restarted why;
> +	enum ocfs2_alloc_restarted why = RESTART_NONE;
>  	struct ocfs2_super *osb = OCFS2_SB(inode->i_sb);
>  	struct ocfs2_extent_tree et;
>  	int did_quota = 0;

Oh geeze, are you really sure about this?  __ocfs2_extend_allocation()
is as clear as mud.  What happens when ocfs2_add_inode_data() returns
-EAGAIN and leaves *reason_ret unwritten to?

What are the runtime effects of this bug?
Junxiao Bi Jan. 7, 2015, 2:42 a.m. UTC | #2
On 01/07/2015 08:09 AM, Andrew Morton wrote:
> On Thu, 25 Dec 2014 13:52:16 +0800 Junxiao Bi <junxiao.bi@oracle.com> wrote:
> 
>> Variable "why" is not yet initialized at line 615, fix it.
>>
>> ...
>>
>> --- a/fs/ocfs2/file.c
>> +++ b/fs/ocfs2/file.c
>> @@ -569,7 +569,7 @@ static int __ocfs2_extend_allocation(struct inode *inode, u32 logical_start,
>>  	handle_t *handle = NULL;
>>  	struct ocfs2_alloc_context *data_ac = NULL;
>>  	struct ocfs2_alloc_context *meta_ac = NULL;
>> -	enum ocfs2_alloc_restarted why;
>> +	enum ocfs2_alloc_restarted why = RESTART_NONE;
>>  	struct ocfs2_super *osb = OCFS2_SB(inode->i_sb);
>>  	struct ocfs2_extent_tree et;
>>  	int did_quota = 0;
> 
> Oh geeze, are you really sure about this?  __ocfs2_extend_allocation()
> is as clear as mud.  What happens when ocfs2_add_inode_data() returns
> -EAGAIN and leaves *reason_ret unwritten to?
*reason_ret will always be written when ocfs2_add_inode_data() return.
> 
> What are the runtime effects of this bug?

I didn't see any other effects except a compile warning and an
uninitialized variable from the tracepoint.

Thanks,
Junxiao.
>
diff mbox

Patch

diff --git a/fs/ocfs2/file.c b/fs/ocfs2/file.c
index 3950693..245db4f 100644
--- a/fs/ocfs2/file.c
+++ b/fs/ocfs2/file.c
@@ -569,7 +569,7 @@  static int __ocfs2_extend_allocation(struct inode *inode, u32 logical_start,
 	handle_t *handle = NULL;
 	struct ocfs2_alloc_context *data_ac = NULL;
 	struct ocfs2_alloc_context *meta_ac = NULL;
-	enum ocfs2_alloc_restarted why;
+	enum ocfs2_alloc_restarted why = RESTART_NONE;
 	struct ocfs2_super *osb = OCFS2_SB(inode->i_sb);
 	struct ocfs2_extent_tree et;
 	int did_quota = 0;