]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
hfs/hfxplus: use kzalloc_flex()
authorRosen Penev <rosenp@gmail.com>
Sat, 25 Apr 2026 01:44:41 +0000 (18:44 -0700)
committerViacheslav Dubeyko <slava@dubeyko.com>
Mon, 27 Apr 2026 22:23:06 +0000 (15:23 -0700)
Instead of doing the math manually, use kzalloc_flex() which does it in
a cleaner way.

Also clarifies which is the flexible array member.

Signed-off-by: Rosen Penev <rosenp@gmail.com>
Reviewed-by: Viacheslav Dubeyko <slava@dubeyko.com>
Signed-off-by: Viacheslav Dubeyko <slava@dubeyko.com>
Link: https://lore.kernel.org/r/20260425014441.441252-1-rosenp@gmail.com
Signed-off-by: Viacheslav Dubeyko <slava@dubeyko.com>
fs/hfs/bnode.c
fs/hfsplus/bnode.c

index 13d58c51fc46bf42b322ce59d97785a793cf3cc4..b0165de7640dbbeaef2bfe351bfdeacaa30fda52 100644 (file)
@@ -344,7 +344,7 @@ static struct hfs_bnode *__hfs_bnode_create(struct hfs_btree *tree, u32 cnid)
        struct hfs_bnode *node, *node2;
        struct address_space *mapping;
        struct page *page;
-       int size, block, i, hash;
+       int block, i, hash;
        loff_t off;
 
        if (cnid >= tree->node_count) {
@@ -352,9 +352,7 @@ static struct hfs_bnode *__hfs_bnode_create(struct hfs_btree *tree, u32 cnid)
                return NULL;
        }
 
-       size = sizeof(struct hfs_bnode) + tree->pages_per_bnode *
-               sizeof(struct page *);
-       node = kzalloc(size, GFP_KERNEL);
+       node = kzalloc_flex(*node, page, tree->pages_per_bnode, GFP_KERNEL);
        if (!node)
                return NULL;
        node->tree = tree;
index f8b5a8ae58ff5859189af4e5262f5baf37382511..a717fa008ddd1a4c5a6b38b52ae72b66020b1a41 100644 (file)
@@ -455,7 +455,7 @@ static struct hfs_bnode *__hfs_bnode_create(struct hfs_btree *tree, u32 cnid)
        struct hfs_bnode *node, *node2;
        struct address_space *mapping;
        struct page *page;
-       int size, block, i, hash;
+       int block, i, hash;
        loff_t off;
 
        if (cnid >= tree->node_count) {
@@ -464,9 +464,7 @@ static struct hfs_bnode *__hfs_bnode_create(struct hfs_btree *tree, u32 cnid)
                return NULL;
        }
 
-       size = sizeof(struct hfs_bnode) + tree->pages_per_bnode *
-               sizeof(struct page *);
-       node = kzalloc(size, GFP_KERNEL);
+       node = kzalloc_flex(*node, page, tree->pages_per_bnode);
        if (!node)
                return NULL;
        node->tree = tree;