Skip to content

Commit fdc8522

Browse files
danobihtejun
authored andcommitted
kernfs: kvmalloc xattr value instead of kmalloc
xattr values have a 64k maximum size. This can result in an order 4 kmalloc request which can be difficult to fulfill. Since xattrs do not need physically contiguous memory, we can switch to kvmalloc and not have to worry about higher order allocations failing. Signed-off-by: Daniel Xu <[email protected]> Acked-by: Chris Down <[email protected]> Reviewed-by: Andreas Dilger <[email protected]> Reviewed-by: Greg Kroah-Hartman <[email protected]> Signed-off-by: Tejun Heo <[email protected]>
1 parent e7b20d9 commit fdc8522

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

fs/xattr.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -817,7 +817,7 @@ struct simple_xattr *simple_xattr_alloc(const void *value, size_t size)
817817
if (len < sizeof(*new_xattr))
818818
return NULL;
819819

820-
new_xattr = kmalloc(len, GFP_KERNEL);
820+
new_xattr = kvmalloc(len, GFP_KERNEL);
821821
if (!new_xattr)
822822
return NULL;
823823

@@ -882,7 +882,7 @@ int simple_xattr_set(struct simple_xattrs *xattrs, const char *name,
882882

883883
new_xattr->name = kstrdup(name, GFP_KERNEL);
884884
if (!new_xattr->name) {
885-
kfree(new_xattr);
885+
kvfree(new_xattr);
886886
return -ENOMEM;
887887
}
888888
}
@@ -912,7 +912,7 @@ int simple_xattr_set(struct simple_xattrs *xattrs, const char *name,
912912
spin_unlock(&xattrs->lock);
913913
if (xattr) {
914914
kfree(xattr->name);
915-
kfree(xattr);
915+
kvfree(xattr);
916916
}
917917
return err;
918918

0 commit comments

Comments
 (0)