Skip to content

Commit b228b8e

Browse files
Michael HalcrowLinus Torvalds
authored andcommitted
[PATCH] eCryptfs: fix possible NULL ptr deref in ecryptfs_d_release()
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>
1 parent ad28d94 commit b228b8e

1 file changed

Lines changed: 5 additions & 10 deletions

File tree

‎fs/ecryptfs/dentry.c‎

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -78,18 +78,13 @@ struct kmem_cache *ecryptfs_dentry_info_cache;
7878
*/
7979
static void ecryptfs_d_release(struct dentry *dentry)
8080
{
81-
struct dentry *lower_dentry;
82-
83-
lower_dentry = ecryptfs_dentry_to_lower(dentry);
84-
if (ecryptfs_dentry_to_private(dentry))
81+
if (ecryptfs_dentry_to_private(dentry)) {
82+
if (ecryptfs_dentry_to_lower(dentry)) {
83+
mntput(ecryptfs_dentry_to_lower_mnt(dentry));
84+
dput(ecryptfs_dentry_to_lower(dentry));
85+
}
8586
kmem_cache_free(ecryptfs_dentry_info_cache,
8687
ecryptfs_dentry_to_private(dentry));
87-
if (lower_dentry) {
88-
struct vfsmount *lower_mnt =
89-
ecryptfs_dentry_to_lower_mnt(dentry);
90-
91-
mntput(lower_mnt);
92-
dput(lower_dentry);
9388
}
9489
return;
9590
}

0 commit comments

Comments
 (0)