projects
/
linux-2.6-block.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
de183b2
)
ext4: use struct_size() to improve ext4_htree_store_dirent()
author
Thorsten Blum
<thorsten.blum@linux.dev>
Tue, 5 Nov 2024 10:33:54 +0000
(11:33 +0100)
committer
Theodore Ts'o
<tytso@mit.edu>
Wed, 13 Nov 2024 17:56:48 +0000
(12:56 -0500)
Inline and use struct_size() to calculate the number of bytes to
allocate for new_fn and remove the local variable len.
Reviewed-by: Jan Kara <jack@suse.cz>
Signed-off-by: Thorsten Blum <thorsten.blum@linux.dev>
Link:
https://patch.msgid.link/20241105103353.11590-2-thorsten.blum@linux.dev
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
fs/ext4/dir.c
patch
|
blob
|
blame
|
history
diff --git
a/fs/ext4/dir.c
b/fs/ext4/dir.c
index 233479647f1b8bbc85765a6ac465dc6bd75cc461..02d47a64e8d13b56da1a444f332d7be438a57d35 100644
(file)
--- a/
fs/ext4/dir.c
+++ b/
fs/ext4/dir.c
@@
-471,14
+471,13
@@
int ext4_htree_store_dirent(struct file *dir_file, __u32 hash,
struct rb_node **p, *parent = NULL;
struct fname *fname, *new_fn;
struct dir_private_info *info;
- int len;
info = dir_file->private_data;
p = &info->root.rb_node;
/* Create and allocate the fname structure */
- len = sizeof(struct fname) + ent_name->len + 1;
-
new_fn = kzalloc(len,
GFP_KERNEL);
+ new_fn = kzalloc(struct_size(new_fn, name, ent_name->len + 1),
+
GFP_KERNEL);
if (!new_fn)
return -ENOMEM;
new_fn->hash = hash;