public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Michael Halcrow <mhalcrow@us.ibm.com>
To: akpm@osdl.org
Cc: linux-kernel@vger.kernel.org
Subject: [PATCH] Fix premature release of file_info memory in eCryptfs
Date: Tue, 30 May 2006 14:08:53 -0500	[thread overview]
Message-ID: <20060530190853.GC3098@us.ibm.com> (raw)

The file_info struct is being released, and then one of its members is
referenced from the released memory. This patch cleans up the function
and moves the release so that it occurs after the reference.

Signed-off-by: Michael Halcrow <mhalcrow@us.ibm.com>

---

 fs/ecryptfs/file.c |   15 ++++++---------
 1 files changed, 6 insertions(+), 9 deletions(-)

1e22635a873a0b0179a8b033e75234dd83a3bb9f
diff --git a/fs/ecryptfs/file.c b/fs/ecryptfs/file.c
index c4ea9f0..b9cdb85 100644
--- a/fs/ecryptfs/file.c
+++ b/fs/ecryptfs/file.c
@@ -304,18 +304,15 @@ static int ecryptfs_flush(struct file *f
 	return rc;
 }
 
-static int ecryptfs_release(struct inode *ecryptfs_inode, struct file *file)
+static int ecryptfs_release(struct inode *inode, struct file *file)
 {
-	struct file *lower_file;
-	struct ecryptfs_file_info *file_info;
-	struct inode *lower_inode;
+	struct file *lower_file = ecryptfs_file_to_lower(file);
+	struct ecryptfs_file_info *file_info = ecryptfs_file_to_private(file);
+	struct inode *lower_inode = ecryptfs_inode_to_lower(inode);
 
-	file_info = ecryptfs_file_to_private(file);
-	kmem_cache_free(ecryptfs_file_info_cache, file_info);
-	lower_file = ecryptfs_file_to_lower(file);
 	fput(lower_file);
-	lower_inode = ecryptfs_inode_to_lower(ecryptfs_inode);
-	ecryptfs_inode->i_blocks = lower_inode->i_blocks;
+	inode->i_blocks = lower_inode->i_blocks;
+	kmem_cache_free(ecryptfs_file_info_cache, file_info);
 	return 0;
 }
 
-- 
1.3.3


                 reply	other threads:[~2006-05-30 19:09 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=20060530190853.GC3098@us.ibm.com \
    --to=mhalcrow@us.ibm.com \
    --cc=akpm@osdl.org \
    --cc=linux-kernel@vger.kernel.org \
    /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
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox