From: Ilia Mirkin Date: Wed, 25 May 2011 00:13:30 +0000 (-0700) Subject: lru_cache: use correct type in sizeof for allocation X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=a08aa355af18c53f17f499c1cc6e2af66a77ba9b;p=GitHub%2Fmoto-9609%2Fandroid_kernel_motorola_exynos9610.git 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: // @@ type T; identifier x; @@ T *x; ... * x = kzalloc(... * sizeof(T*) * ..., ...); // [akpm@linux-foundation.org: use kcalloc()] Signed-off-by: Ilia Mirkin Acked-by: Lars Ellenberg Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- 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, if (e_count > LC_MAX_ACTIVE) return NULL; - slot = kzalloc(e_count * sizeof(struct hlist_head*), GFP_KERNEL); + slot = kcalloc(e_count, sizeof(struct hlist_head), GFP_KERNEL); if (!slot) goto out_fail; element = kzalloc(e_count * sizeof(struct lc_element *), GFP_KERNEL);