Skip to content

Commit f945ca1

Browse files
author
Miklos Szeredi
committed
ovl: use kvalloc in xattr copy-up
Extended attributes are usually small, but could be up to 64k in size, so use the most efficient method for doing the allocation. Signed-off-by: Miklos Szeredi <[email protected]>
1 parent d8991e8 commit f945ca1

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

fs/overlayfs/copy_up.c

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ int ovl_copy_xattr(struct super_block *sb, struct dentry *old,
6363
return list_size;
6464
}
6565

66-
buf = kzalloc(list_size, GFP_KERNEL);
66+
buf = kvzalloc(list_size, GFP_KERNEL);
6767
if (!buf)
6868
return -ENOMEM;
6969

@@ -106,11 +106,12 @@ int ovl_copy_xattr(struct super_block *sb, struct dentry *old,
106106
if (size > value_size) {
107107
void *new;
108108

109-
new = krealloc(value, size, GFP_KERNEL);
109+
new = kvmalloc(size, GFP_KERNEL);
110110
if (!new) {
111111
error = -ENOMEM;
112112
break;
113113
}
114+
kvfree(value);
114115
value = new;
115116
value_size = size;
116117
goto retry;
@@ -125,9 +126,9 @@ int ovl_copy_xattr(struct super_block *sb, struct dentry *old,
125126
error = 0;
126127
}
127128
}
128-
kfree(value);
129+
kvfree(value);
129130
out:
130-
kfree(buf);
131+
kvfree(buf);
131132
return error;
132133
}
133134

0 commit comments

Comments
 (0)