--- fs/xattr.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) --- a/fs/xattr.c +++ b/fs/xattr.c @@ -383,7 +383,10 @@ vfs_getxattr_alloc(struct user_namespace } error = handler->get(handler, dentry, inode, name, value, error); - *xattr_value = value; + if (error < 0 && value != *xattr_value) + kfree(value); + else + *xattr_value = value; return error; }