From mboxrd@z Thu Jan 1 00:00:00 1970 From: SF Markus Elfring Subject: [PATCH 01/16] md/bitmap: Use kmalloc_array() in bitmap_storage_alloc() Date: Tue, 27 Sep 2016 18:45:51 +0200 Message-ID: References: <566ABCD9.1060404@users.sourceforge.net> <30938c84-20a7-0f13-bdda-a2d2109a6dac@users.sourceforge.net> Mime-Version: 1.0 Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <30938c84-20a7-0f13-bdda-a2d2109a6dac@users.sourceforge.net> Sender: kernel-janitors-owner@vger.kernel.org To: linux-raid@vger.kernel.org, Shaohua Li Cc: LKML , kernel-janitors@vger.kernel.org, Julia Lawall List-Id: linux-raid.ids From: Markus Elfring Date: Tue, 27 Sep 2016 13:01:07 +0200 * A multiplication for the size determination of a memory allocation indicated that an array data structure should be processed. Thus use the corresponding function "kmalloc_array". This issue was detected by using the Coccinelle software. * Replace the specification of a data type by a pointer dereference to make the corresponding size determination a bit safer according to the Linux coding style convention. Signed-off-by: Markus Elfring --- drivers/md/bitmap.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/md/bitmap.c b/drivers/md/bitmap.c index 13041ee..8cfb02c 100644 --- a/drivers/md/bitmap.c +++ b/drivers/md/bitmap.c @@ -760,9 +760,9 @@ static int bitmap_storage_alloc(struct bitmap_storage *store, num_pages = DIV_ROUND_UP(bytes, PAGE_SIZE); offset = slot_number * num_pages; - - store->filemap = kmalloc(sizeof(struct page *) - * num_pages, GFP_KERNEL); + store->filemap = kmalloc_array(num_pages, + sizeof(*store->filemap), + GFP_KERNEL); if (!store->filemap) return -ENOMEM; -- 2.10.0