Skip to content

Commit

Permalink
[PATCH] eCryptfs: fix possible NULL ptr deref in ecryptfs_d_release()
Browse files Browse the repository at this point in the history
ecryptfs_d_release() first dereferences a pointer (via
ecryptfs_dentry_to_lower()) and then afterwards checks to see if the
pointer it just dereferenced is NULL (via ecryptfs_dentry_to_private()).

This patch moves all of the work done on the dereferenced pointer inside a
block governed by the condition that the pointer is non-NULL.

Signed-off-by: Michael Halcrow <mhalcrow@us.ibm.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
  • Loading branch information
Michael Halcrow authored and Linus Torvalds committed Mar 17, 2007
1 parent ad28d94 commit b228b8e
Showing 1 changed file with 5 additions and 10 deletions.
15 changes: 5 additions & 10 deletions fs/ecryptfs/dentry.c
Original file line number Diff line number Diff line change
Expand Up @@ -78,18 +78,13 @@ struct kmem_cache *ecryptfs_dentry_info_cache;
*/
static void ecryptfs_d_release(struct dentry *dentry)
{
struct dentry *lower_dentry;

lower_dentry = ecryptfs_dentry_to_lower(dentry);
if (ecryptfs_dentry_to_private(dentry))
if (ecryptfs_dentry_to_private(dentry)) {
if (ecryptfs_dentry_to_lower(dentry)) {
mntput(ecryptfs_dentry_to_lower_mnt(dentry));
dput(ecryptfs_dentry_to_lower(dentry));
}
kmem_cache_free(ecryptfs_dentry_info_cache,
ecryptfs_dentry_to_private(dentry));
if (lower_dentry) {
struct vfsmount *lower_mnt =
ecryptfs_dentry_to_lower_mnt(dentry);

mntput(lower_mnt);
dput(lower_dentry);
}
return;
}
Expand Down

0 comments on commit b228b8e

Please sign in to comment.