diff options
author | Ilia Mirkin <imirkin@alum.mit.edu> | 2011-05-24 20:13:30 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2011-05-25 11:39:52 -0400 |
commit | a08aa355af18c53f17f499c1cc6e2af66a77ba9b (patch) | |
tree | 1eea598cd9000361a30ddf521bca0022aee7d52b | |
parent | 4440673a95e63ad888a41db596edaa0c55d3a332 (diff) |
lru_cache: use correct type in sizeof for allocation
This has no actual effect, since sizeof(struct hlist_head) ==
sizeof(struct hlist_head *), but it's still the wrong type to use.
The semantic match that finds this problem:
// <smpl>
@@
type T;
identifier x;
@@
T *x;
...
* x = kzalloc(... * sizeof(T*) * ..., ...);
// </smpl>
[akpm@linux-foundation.org: use kcalloc()]
Signed-off-by: Ilia Mirkin <imirkin@alum.mit.edu>
Acked-by: Lars Ellenberg <lars@linbit.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
-rw-r--r-- | lib/lru_cache.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/lib/lru_cache.c b/lib/lru_cache.c index 270de9d31b8c..a07e7268d7ed 100644 --- a/lib/lru_cache.c +++ b/lib/lru_cache.c | |||
@@ -84,7 +84,7 @@ struct lru_cache *lc_create(const char *name, struct kmem_cache *cache, | |||
84 | if (e_count > LC_MAX_ACTIVE) | 84 | if (e_count > LC_MAX_ACTIVE) |
85 | return NULL; | 85 | return NULL; |
86 | 86 | ||
87 | slot = kzalloc(e_count * sizeof(struct hlist_head*), GFP_KERNEL); | 87 | slot = kcalloc(e_count, sizeof(struct hlist_head), GFP_KERNEL); |
88 | if (!slot) | 88 | if (!slot) |
89 | goto out_fail; | 89 | goto out_fail; |
90 | element = kzalloc(e_count * sizeof(struct lc_element *), GFP_KERNEL); | 90 | element = kzalloc(e_count * sizeof(struct lc_element *), GFP_KERNEL); |