Commit cf4ef780 authored by Stanislav Goriainov's avatar Stanislav Goriainov Committed by Miklos Szeredi

ovl: Add comment on upperredirect reassignment

If memory for uperredirect was allocated with kstrdup() in upperdir != NULL
and d.redirect != NULL path, it may seem that it can be lost when
upperredirect is reassigned later, but it's not possible.

Found by Linux Verification Center (linuxtesting.org) with SVACE.

Fixes: 0a2d0d3f ("ovl: Check redirect on index as well")
Signed-off-by: default avatarStanislav Goriainov <goriainov@ispras.ru>
Signed-off-by: default avatarMiklos Szeredi <mszeredi@redhat.com>
parent af4dcb6d
...@@ -1086,6 +1086,11 @@ struct dentry *ovl_lookup(struct inode *dir, struct dentry *dentry, ...@@ -1086,6 +1086,11 @@ struct dentry *ovl_lookup(struct inode *dir, struct dentry *dentry,
.mnt = ovl_upper_mnt(ofs), .mnt = ovl_upper_mnt(ofs),
}; };
/*
* It's safe to assign upperredirect here: the previous
* assignment of happens only if upperdentry is non-NULL, and
* this one only if upperdentry is NULL.
*/
upperredirect = ovl_get_redirect_xattr(ofs, &upperpath, 0); upperredirect = ovl_get_redirect_xattr(ofs, &upperpath, 0);
if (IS_ERR(upperredirect)) { if (IS_ERR(upperredirect)) {
err = PTR_ERR(upperredirect); err = PTR_ERR(upperredirect);
......
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