linux-ext4.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] ext3: Fix not initialized hash info in ext3_dx_find_entry()
@ 2007-08-30 14:42 Wang Chen
  2007-08-30 15:29 ` Theodore Tso
  0 siblings, 1 reply; 3+ messages in thread
From: Wang Chen @ 2007-08-30 14:42 UTC (permalink / raw)
  To: linux-ext4; +Cc: Wang Chen

- In fs/ext3/namei.c, Variable "hinfo" may be referenced before it has
been set with a value.

Signed-off-by: Wang Chen <wangchen@cn.fujitsu.com>
---

diff -Nurp linux-2.6.22.4.org/fs/ext3/namei.c linux-2.6.22.4/fs/ext3/namei.c
--- linux-2.6.22.4.org/fs/ext3/namei.c  2007-08-22 15:33:40.000000000 +0800
+++ linux-2.6.22.4/fs/ext3/namei.c      2007-08-28 17:47:44.000000000 +0800
@@ -952,6 +952,12 @@ static struct buffer_head * ext3_dx_find
                frame->bh = NULL;                       /* for dx_release() */
                frame->at = (struct dx_entry *)frames;  /* hack for zero entry*/
                dx_set_block(frame->at, 0);             /* dx_root block is 0 */
+               if (dentry){
+                       ext3fs_dirhash(dentry->d_name.name, dentry->d_name.len,
+                                      &hinfo);
+               } else {
+                       return NULL;
+               }
        }
        hash = hinfo.hash;
        do {

--
Wang Chen 

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

* Re: [PATCH] ext3: Fix not initialized hash info in ext3_dx_find_entry()
  2007-08-30 14:42 [PATCH] ext3: Fix not initialized hash info in ext3_dx_find_entry() Wang Chen
@ 2007-08-30 15:29 ` Theodore Tso
  2007-08-31  1:34   ` FNST-Wang Chen
  0 siblings, 1 reply; 3+ messages in thread
From: Theodore Tso @ 2007-08-30 15:29 UTC (permalink / raw)
  To: Wang Chen; +Cc: linux-ext4, Wang Chen

On Thu, Aug 30, 2007 at 10:42:33PM +0800, Wang Chen wrote:
> +               if (dentry){
> +                       ext3fs_dirhash(dentry->d_name.name, 
> dentry->d_name.len,
> +                                      &hinfo);
> +               } else {
> +                       return NULL;
> +               }

It's really not necessary to call ext3fs_dirhash(), since we don't
need the hash value for the '.' and '..' case.  So here's a better
patch....

     	      	    	    	- Ted

>From c2ff518e6f529f1d8b627f0e8be5d6f8af32747f Mon Sep 17 00:00:00 2001
From: Theodore Ts'o <tytso@mit.edu>
Date: Thu, 30 Aug 2007 11:26:24 -0400
Subject: [PATCH] ext3: Fix use of uninitialized variable in ext3_dx_find_entry()

In the case where we are looking up '.' and '..', those files are
always in the first directory block, so we don't need worry about the
hash value.  This avoids a lint warning message, as a minor cleanup.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
---
 fs/ext3/namei.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/fs/ext3/namei.c b/fs/ext3/namei.c
index 1586807..c278fc7 100644
--- a/fs/ext3/namei.c
+++ b/fs/ext3/namei.c
@@ -932,7 +932,7 @@ static struct buffer_head * ext3_dx_find_entry(struct dentry *dentry,
 {
 	struct super_block * sb;
 	struct dx_hash_info	hinfo;
-	u32 hash;
+	u32 hash = 0;
 	struct dx_frame frames[2], *frame;
 	struct ext3_dir_entry_2 *de, *top;
 	struct buffer_head *bh;
@@ -947,13 +947,13 @@ static struct buffer_head * ext3_dx_find_entry(struct dentry *dentry,
 	if (namelen > 2 || name[0] != '.'||(name[1] != '.' && name[1] != '\0')){
 		if (!(frame = dx_probe(dentry, NULL, &hinfo, frames, err)))
 			return NULL;
+		hash = hinfo.hash;
 	} else {
 		frame = frames;
 		frame->bh = NULL;			/* for dx_release() */
 		frame->at = (struct dx_entry *)frames;	/* hack for zero entry*/
 		dx_set_block(frame->at, 0);		/* dx_root block is 0 */
 	}
-	hash = hinfo.hash;
 	do {
 		block = dx_get_block(frame->at);
 		if (!(bh = ext3_bread (NULL,dir, block, 0, err)))
-- 
1.5.3.rc6.23.g0058

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

* Re: [PATCH] ext3: Fix not initialized hash info in ext3_dx_find_entry()
  2007-08-30 15:29 ` Theodore Tso
@ 2007-08-31  1:34   ` FNST-Wang Chen
  0 siblings, 0 replies; 3+ messages in thread
From: FNST-Wang Chen @ 2007-08-31  1:34 UTC (permalink / raw)
  To: Theodore Tso; +Cc: Wang Chen, linux-ext4

Agree, thanks.

Theodore Tso said the following on 2007-8-30 23:29:
> On Thu, Aug 30, 2007 at 10:42:33PM +0800, Wang Chen wrote:
>   
>> +               if (dentry){
>> +                       ext3fs_dirhash(dentry->d_name.name, 
>> dentry->d_name.len,
>> +                                      &hinfo);
>> +               } else {
>> +                       return NULL;
>> +               }
>>     
>
> It's really not necessary to call ext3fs_dirhash(), since we don't
> need the hash value for the '.' and '..' case.  So here's a better
> patch....
>
>      	      	    	    	- Ted
>
> >From c2ff518e6f529f1d8b627f0e8be5d6f8af32747f Mon Sep 17 00:00:00 2001
> From: Theodore Ts'o <tytso@mit.edu>
> Date: Thu, 30 Aug 2007 11:26:24 -0400
> Subject: [PATCH] ext3: Fix use of uninitialized variable in ext3_dx_find_entry()
>
> In the case where we are looking up '.' and '..', those files are
> always in the first directory block, so we don't need worry about the
> hash value.  This avoids a lint warning message, as a minor cleanup.
>
> Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
> ---
>  fs/ext3/namei.c |    4 ++--
>  1 files changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/fs/ext3/namei.c b/fs/ext3/namei.c
> index 1586807..c278fc7 100644
> --- a/fs/ext3/namei.c
> +++ b/fs/ext3/namei.c
> @@ -932,7 +932,7 @@ static struct buffer_head * ext3_dx_find_entry(struct dentry *dentry,
>  {
>  	struct super_block * sb;
>  	struct dx_hash_info	hinfo;
> -	u32 hash;
> +	u32 hash = 0;
>  	struct dx_frame frames[2], *frame;
>  	struct ext3_dir_entry_2 *de, *top;
>  	struct buffer_head *bh;
> @@ -947,13 +947,13 @@ static struct buffer_head * ext3_dx_find_entry(struct dentry *dentry,
>  	if (namelen > 2 || name[0] != '.'||(name[1] != '.' && name[1] != '\0')){
>  		if (!(frame = dx_probe(dentry, NULL, &hinfo, frames, err)))
>  			return NULL;
> +		hash = hinfo.hash;
>  	} else {
>  		frame = frames;
>  		frame->bh = NULL;			/* for dx_release() */
>  		frame->at = (struct dx_entry *)frames;	/* hack for zero entry*/
>  		dx_set_block(frame->at, 0);		/* dx_root block is 0 */
>  	}
> -	hash = hinfo.hash;
>  	do {
>  		block = dx_get_block(frame->at);
>  		if (!(bh = ext3_bread (NULL,dir, block, 0, err)))
>   


-- 
Best Regards,
A new email address of FJWAN is launched from Apr.1 2007.
The updated address is: wangchen@cn.fujitsu.com
--------------------------------------------------
Wang Chen
Development Dept.I
Nanjing Fujitsu Nanda Software Tech. Co., Ltd.(FNST)
8/F., Civil Defense Building, No.189 Guangzhou Road,
Nanjing, 210029, China
TEL:+86+25-86630566-850
FUJITSU INTERNAL:79955-850
FAX:+86+25-83317685
MAIL:wangchen@cn.fujitsu.com
--------------------------------------------------

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

end of thread, other threads:[~2007-08-31  1:34 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-08-30 14:42 [PATCH] ext3: Fix not initialized hash info in ext3_dx_find_entry() Wang Chen
2007-08-30 15:29 ` Theodore Tso
2007-08-31  1:34   ` FNST-Wang Chen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).