Merge PR #22611 into master

* refs/pull/22611/head:
	client: fix use-after-free in Client::link()

Reviewed-by: Patrick Donnelly <pdonnell@redhat.com>
This commit is contained in:
Patrick Donnelly 2018-06-26 13:25:29 -07:00
commit ad3aee3a57
No known key found for this signature in database
GPG Key ID: 3A2A7E25BEA8AADB

View File

@ -2978,8 +2978,10 @@ Dentry* Client::link(Dir *dir, const string& name, Inode *in, Dentry *dn)
}
if (in) { // link to inode
InodeRef tmp_ref;
// only one parent for directories!
if (in->is_dir() && !in->dentries.empty()) {
tmp_ref = in; // prevent unlink below from freeing the inode.
Dentry *olddn = in->get_first_parent();
assert(olddn->dir != dir || olddn->name != name);
Inode *old_diri = olddn->dir->parent_inode;