aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAmir Goldstein <amir73il@gmail.com>2017-09-24 15:19:10 -0400
committerMiklos Szeredi <mszeredi@redhat.com>2017-10-05 09:53:18 -0400
commitdc7ab6773e8171e07f16fd0df0c5eea28c899503 (patch)
treec02dbf8207d2c36f1bab680fa453428205221b50
parent9f4ec904dbd4eb1a2db10d5e7dc16eae386fe64d (diff)
ovl: fix dentry leak in ovl_indexdir_cleanup()
index dentry was not released when breaking out of the loop due to index verification error. Fixes: 415543d5c64f ("ovl: cleanup bad and stale index entries on mount") Cc: <stable@vger.kernel.org> # v4.13 Signed-off-by: Amir Goldstein <amir73il@gmail.com> Signed-off-by: Miklos Szeredi <mszeredi@redhat.com>
-rw-r--r--fs/overlayfs/readdir.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/fs/overlayfs/readdir.c b/fs/overlayfs/readdir.c
index 62e9b22a2077..0f85ee9c3268 100644
--- a/fs/overlayfs/readdir.c
+++ b/fs/overlayfs/readdir.c
@@ -988,6 +988,7 @@ int ovl_indexdir_cleanup(struct dentry *dentry, struct vfsmount *mnt,
988 struct path *lowerstack, unsigned int numlower) 988 struct path *lowerstack, unsigned int numlower)
989{ 989{
990 int err; 990 int err;
991 struct dentry *index = NULL;
991 struct inode *dir = dentry->d_inode; 992 struct inode *dir = dentry->d_inode;
992 struct path path = { .mnt = mnt, .dentry = dentry }; 993 struct path path = { .mnt = mnt, .dentry = dentry };
993 LIST_HEAD(list); 994 LIST_HEAD(list);
@@ -1007,8 +1008,6 @@ int ovl_indexdir_cleanup(struct dentry *dentry, struct vfsmount *mnt,
1007 1008
1008 inode_lock_nested(dir, I_MUTEX_PARENT); 1009 inode_lock_nested(dir, I_MUTEX_PARENT);
1009 list_for_each_entry(p, &list, l_node) { 1010 list_for_each_entry(p, &list, l_node) {
1010 struct dentry *index;
1011
1012 if (p->name[0] == '.') { 1011 if (p->name[0] == '.') {
1013 if (p->len == 1) 1012 if (p->len == 1)
1014 continue; 1013 continue;
@@ -1018,6 +1017,7 @@ int ovl_indexdir_cleanup(struct dentry *dentry, struct vfsmount *mnt,
1018 index = lookup_one_len(p->name, dentry, p->len); 1017 index = lookup_one_len(p->name, dentry, p->len);
1019 if (IS_ERR(index)) { 1018 if (IS_ERR(index)) {
1020 err = PTR_ERR(index); 1019 err = PTR_ERR(index);
1020 index = NULL;
1021 break; 1021 break;
1022 } 1022 }
1023 err = ovl_verify_index(index, lowerstack, numlower); 1023 err = ovl_verify_index(index, lowerstack, numlower);
@@ -1029,7 +1029,9 @@ int ovl_indexdir_cleanup(struct dentry *dentry, struct vfsmount *mnt,
1029 break; 1029 break;
1030 } 1030 }
1031 dput(index); 1031 dput(index);
1032 index = NULL;
1032 } 1033 }
1034 dput(index);
1033 inode_unlock(dir); 1035 inode_unlock(dir);
1034out: 1036out:
1035 ovl_cache_free(&list); 1037 ovl_cache_free(&list);