[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <1558078008-15737-1-git-send-email-xiaolinkui@kylinos.cn>
Date: Fri, 17 May 2019 15:26:48 +0800
From: xiaolinkui <xiaolinkui@...inos.cn>
To: james.morris@...rosoft.com, gustavo@...eddedor.com,
dhowells@...hat.com, akpm@...ux-foundation.org
Cc: linux-kernel@...r.kernel.org, xiaolinkui@...inos.cn
Subject: [PATCH 1/3] lib: assoc_array: use struct_size() in kmalloc()
Use the new struct_size() helper to keep code simple.
Signed-off-by: xiaolinkui <xiaolinkui@...inos.cn>
---
lib/assoc_array.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/lib/assoc_array.c b/lib/assoc_array.c
index edc3c14..0e69b5b 100644
--- a/lib/assoc_array.c
+++ b/lib/assoc_array.c
@@ -1494,8 +1494,7 @@ int assoc_array_gc(struct assoc_array *array,
shortcut = assoc_array_ptr_to_shortcut(cursor);
keylen = round_up(shortcut->skip_to_level, ASSOC_ARRAY_KEY_CHUNK_SIZE);
keylen >>= ASSOC_ARRAY_KEY_CHUNK_SHIFT;
- new_s = kmalloc(sizeof(struct assoc_array_shortcut) +
- keylen * sizeof(unsigned long), GFP_KERNEL);
+ new_s = kmalloc(struct_size(new_s, index_key, keylen), GFP_KERNEL);
if (!new_s)
goto enomem;
pr_devel("dup shortcut %p -> %p\n", shortcut, new_s);
--
2.7.4
Powered by blists - more mailing lists