LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
From: Chris Wright <chrisw@osdl.org>
To: Mingming Cao <cmm@us.ibm.com>
Cc: Andrew Morton <akpm@osdl.org>,
	ext2-devel@lists.sourceforge.net, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] use-before-uninitialized value in ext3(2)_find_ goal
Date: Wed, 19 May 2004 12:53:28 -0700	[thread overview]
Message-ID: <20040519125328.J22989@build.pdx.osdl.net> (raw)
In-Reply-To: <1084992705.15395.1276.camel@w-ming2.beaverton.ibm.com>; from cmm@us.ibm.com on Wed, May 19, 2004 at 11:51:43AM -0700

* Mingming Cao (cmm@us.ibm.com) wrote:
> +	goal = 0;
>  	down(&ei->truncate_sem);
>  	if (ext3_find_goal(inode, iblock, chain, partial, &goal) < 0) {
...
> +	goal = 0;
>  	if (ext2_find_goal(inode, iblock, chain, partial, &goal) < 0)
>  		goto changed;

I know it's a slightly bigger patch, but would it make sense to just enforce
this as part of api?  Just a thought...(patch untested)

thanks,
-chris

--- linux-2.6.6-mm3/fs/ext2/inode.c~goal	2004-05-09 19:32:00.000000000 -0700
+++ linux-2.6.6-mm3/fs/ext2/inode.c	2004-05-19 12:27:11.968054560 -0700
@@ -366,6 +366,7 @@ static inline int ext2_find_goal(struct 
 				 unsigned long *goal)
 {
 	struct ext2_inode_info *ei = EXT2_I(inode);
+	unsigned long _goal = 0;
 	write_lock(&ei->i_meta_lock);
 	if (block == ei->i_next_alloc_block + 1) {
 		ei->i_next_alloc_block++;
@@ -377,10 +378,11 @@ static inline int ext2_find_goal(struct 
 		 * failing that at least try to get decent locality.
 		 */
 		if (block == ei->i_next_alloc_block)
-			*goal = ei->i_next_alloc_goal;
-		if (!*goal)
-			*goal = ext2_find_near(inode, partial);
+			_goal = ei->i_next_alloc_goal;
+		if (!_goal)
+			_goal = ext2_find_near(inode, partial);
 		write_unlock(&ei->i_meta_lock);
+		*goal = _goal;
 		return 0;
 	}
 	write_unlock(&ei->i_meta_lock);
--- linux-2.6.6-mm3/fs/ext3/inode.c~goal	2004-05-13 11:19:42.000000000 -0700
+++ linux-2.6.6-mm3/fs/ext3/inode.c	2004-05-19 12:25:48.441752488 -0700
@@ -461,6 +461,7 @@ static int ext3_find_goal(struct inode *
 			  Indirect *partial, unsigned long *goal)
 {
 	struct ext3_inode_info *ei = EXT3_I(inode);
+	unsigned long _goal = 0;
 	/* Writer: ->i_next_alloc* */
 	if (block == ei->i_next_alloc_block + 1) {
 		ei->i_next_alloc_block++;
@@ -474,9 +475,10 @@ static int ext3_find_goal(struct inode *
 		 * failing that at least try to get decent locality.
 		 */
 		if (block == ei->i_next_alloc_block)
-			*goal = ei->i_next_alloc_goal;
-		if (!*goal)
-			*goal = ext3_find_near(inode, partial);
+			_goal = ei->i_next_alloc_goal;
+		if (!_goal)
+			_goal = ext3_find_near(inode, partial);
+		*goal = _goal;
 		return 0;
 	}
 	/* Reader: end */

  reply	other threads:[~2004-05-21 23:57 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20040519043235.30d47edb.akpm@osdl.org>
2004-05-19 18:51 ` Mingming Cao
2004-05-19 19:53   ` Chris Wright [this message]
2004-05-19 20:33     ` [Ext2-devel] " Mingming Cao
2004-05-19 21:06     ` Matthew Wilcox
2004-05-19 22:32       ` Chris Wright

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20040519125328.J22989@build.pdx.osdl.net \
    --to=chrisw@osdl.org \
    --cc=akpm@osdl.org \
    --cc=cmm@us.ibm.com \
    --cc=ext2-devel@lists.sourceforge.net \
    --cc=linux-kernel@vger.kernel.org \
    --subject='Re: [PATCH] use-before-uninitialized value in ext3(2)_find_ goal' \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

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).