Commit dc7ab677 authored by Amir Goldstein's avatar Amir Goldstein Committed by Miklos Szeredi

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: 415543d5 ("ovl: cleanup bad and stale index entries on mount")
Cc: <stable@vger.kernel.org> # v4.13
Signed-off-by: default avatarAmir Goldstein <amir73il@gmail.com>
Signed-off-by: default avatarMiklos Szeredi <mszeredi@redhat.com>
parent 9f4ec904
...@@ -988,6 +988,7 @@ int ovl_indexdir_cleanup(struct dentry *dentry, struct vfsmount *mnt, ...@@ -988,6 +988,7 @@ int ovl_indexdir_cleanup(struct dentry *dentry, struct vfsmount *mnt,
struct path *lowerstack, unsigned int numlower) struct path *lowerstack, unsigned int numlower)
{ {
int err; int err;
struct dentry *index = NULL;
struct inode *dir = dentry->d_inode; struct inode *dir = dentry->d_inode;
struct path path = { .mnt = mnt, .dentry = dentry }; struct path path = { .mnt = mnt, .dentry = dentry };
LIST_HEAD(list); LIST_HEAD(list);
...@@ -1007,8 +1008,6 @@ int ovl_indexdir_cleanup(struct dentry *dentry, struct vfsmount *mnt, ...@@ -1007,8 +1008,6 @@ int ovl_indexdir_cleanup(struct dentry *dentry, struct vfsmount *mnt,
inode_lock_nested(dir, I_MUTEX_PARENT); inode_lock_nested(dir, I_MUTEX_PARENT);
list_for_each_entry(p, &list, l_node) { list_for_each_entry(p, &list, l_node) {
struct dentry *index;
if (p->name[0] == '.') { if (p->name[0] == '.') {
if (p->len == 1) if (p->len == 1)
continue; continue;
...@@ -1018,6 +1017,7 @@ int ovl_indexdir_cleanup(struct dentry *dentry, struct vfsmount *mnt, ...@@ -1018,6 +1017,7 @@ int ovl_indexdir_cleanup(struct dentry *dentry, struct vfsmount *mnt,
index = lookup_one_len(p->name, dentry, p->len); index = lookup_one_len(p->name, dentry, p->len);
if (IS_ERR(index)) { if (IS_ERR(index)) {
err = PTR_ERR(index); err = PTR_ERR(index);
index = NULL;
break; break;
} }
err = ovl_verify_index(index, lowerstack, numlower); err = ovl_verify_index(index, lowerstack, numlower);
...@@ -1029,7 +1029,9 @@ int ovl_indexdir_cleanup(struct dentry *dentry, struct vfsmount *mnt, ...@@ -1029,7 +1029,9 @@ int ovl_indexdir_cleanup(struct dentry *dentry, struct vfsmount *mnt,
break; break;
} }
dput(index); dput(index);
index = NULL;
} }
dput(index);
inode_unlock(dir); inode_unlock(dir);
out: out:
ovl_cache_free(&list); ovl_cache_free(&list);
......
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