Commit b228b8e5 authored by Michael Halcrow's avatar Michael Halcrow Committed by Linus Torvalds

[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: default avatarMichael Halcrow <mhalcrow@us.ibm.com>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent ad28d94a
...@@ -78,18 +78,13 @@ struct kmem_cache *ecryptfs_dentry_info_cache; ...@@ -78,18 +78,13 @@ struct kmem_cache *ecryptfs_dentry_info_cache;
*/ */
static void ecryptfs_d_release(struct dentry *dentry) static void ecryptfs_d_release(struct dentry *dentry)
{ {
struct dentry *lower_dentry; if (ecryptfs_dentry_to_private(dentry)) {
if (ecryptfs_dentry_to_lower(dentry)) {
lower_dentry = ecryptfs_dentry_to_lower(dentry); mntput(ecryptfs_dentry_to_lower_mnt(dentry));
if (ecryptfs_dentry_to_private(dentry)) dput(ecryptfs_dentry_to_lower(dentry));
}
kmem_cache_free(ecryptfs_dentry_info_cache, kmem_cache_free(ecryptfs_dentry_info_cache,
ecryptfs_dentry_to_private(dentry)); 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; return;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment