Skip to content

Commit de7a52c

Browse files
author
Miklos Szeredi
committed
ovl: clean up ovl_getxattr() in copy_up.c
Lose the padding and the failure message (in line with other parts of the copy up process). Return zero for both nonexistent or empty xattr. Signed-off-by: Miklos Szeredi <mszeredi@redhat.com>
1 parent fee0f29 commit de7a52c

1 file changed

Lines changed: 11 additions & 21 deletions

File tree

fs/overlayfs/copy_up.c

Lines changed: 11 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -784,36 +784,26 @@ static bool ovl_need_meta_copy_up(struct dentry *dentry, umode_t mode,
784784
return true;
785785
}
786786

787-
static ssize_t ovl_getxattr(struct dentry *dentry, char *name, char **value,
788-
size_t padding)
787+
static ssize_t ovl_getxattr(struct dentry *dentry, char *name, char **value)
789788
{
790789
ssize_t res;
791-
char *buf = NULL;
790+
char *buf;
792791

793792
res = vfs_getxattr(dentry, name, NULL, 0);
794-
if (res < 0) {
795-
if (res == -ENODATA || res == -EOPNOTSUPP)
796-
return -ENODATA;
797-
goto fail;
798-
}
793+
if (res == -ENODATA || res == -EOPNOTSUPP)
794+
res = 0;
799795

800-
if (res != 0) {
801-
buf = kzalloc(res + padding, GFP_KERNEL);
796+
if (res > 0) {
797+
buf = kzalloc(res, GFP_KERNEL);
802798
if (!buf)
803799
return -ENOMEM;
804800

805801
res = vfs_getxattr(dentry, name, buf, res);
806802
if (res < 0)
807-
goto fail;
803+
kfree(buf);
804+
else
805+
*value = buf;
808806
}
809-
*value = buf;
810-
811-
return res;
812-
813-
fail:
814-
pr_warn_ratelimited("failed to get xattr %s: err=%zi)\n",
815-
name, res);
816-
kfree(buf);
817807
return res;
818808
}
819809

@@ -836,8 +826,8 @@ static int ovl_copy_up_meta_inode_data(struct ovl_copy_up_ctx *c)
836826

837827
if (c->stat.size) {
838828
err = cap_size = ovl_getxattr(upperpath.dentry, XATTR_NAME_CAPS,
839-
&capability, 0);
840-
if (err < 0 && err != -ENODATA)
829+
&capability);
830+
if (cap_size < 0)
841831
goto out;
842832
}
843833

0 commit comments

Comments
 (0)