From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754360AbcIDTKf (ORCPT ); Sun, 4 Sep 2016 15:10:35 -0400 Received: from mout.web.de ([217.72.192.78]:51691 "EHLO mout.web.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751539AbcIDTKb (ORCPT ); Sun, 4 Sep 2016 15:10:31 -0400 To: x86@kernel.org, Borislav Petkov , "H. Peter Anvin" , Ingo Molnar , Paul Gortmaker , Thomas Gleixner Cc: LKML , kernel-janitors@vger.kernel.org, Julia Lawall , Paolo Bonzini From: SF Markus Elfring Subject: [PATCH] x86/amd_nb: Use kmalloc_array() in amd_cache_gart() Message-ID: <3b30d96b-9280-623d-2bcb-c24e2c94e425@users.sourceforge.net> Date: Sun, 4 Sep 2016 21:08:20 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.3.0 MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-Provags-ID: V03:K0:fvC9xahyedbSlvMHukUpIsowFkNx5vToahuvZvSRDQeHDgm3vQ0 R1bkg3x6TaoJnyNsTzk/NncLVwY5/TGwzTTR9SShc1lleBtJp/o0Du8x4ZOcQjYqyPh73HJ AHevJpGMdEyORj04bBC8z2zT2Ap/+HIBmPQ7HHogtSlAu4rdF2V3tsNeS1UG+t9s85TV1Yq BjVPy2+Jrq+ExN0299jTQ== X-UI-Out-Filterresults: notjunk:1;V01:K0:NtboTyqCleU=:tqmOo03TJKw0Ig0adUEFub fbF18l0W6+FyIVwyzN+QsuWXqDyEuKhK1yJ013MO0jdfBcLfCiDW+QmTEi5b2uIGdw5sp4cJ0 vOCpQwZMIoOujXX9GmsadYZLxm+jKy9LItAwzcOdcQeLPFHE8ZHQyIk5SMvTZOeK2kXkkmBE/ jTL6Xo14bFKE+MkbX2eT5eKaaoAIUCr5lJSbd1PvRRMC/DyGCDIPUDCPWe2xaHpJnl6qOH9AW 3Dv1XAkYj9oQudZEid28/vl5KMckqEGMXqp+JSbwJtGCs9kzLo8qawd51P3Q3shcRLb/vrdab UeI5Y8rzPsouK1JsVewvGIV5qjg/DevFE6ARXWG2vGNS73m8IfZfUkp8PRsTFmQvijt7MXxyp t7vcxJxrXLp3h3OYeHU2H76LJEFgGAugxCUfOzPwczxwuCCdTJ356ilcFQdDf+ZiOJrj6koiY x/KmTckKCBcYxbmuFLzhtnuQhXPPXziNKrUr5qtz+OV655nf/K5AQgiohYWHAVgb01SZiJknY 6Hi9GFprbpvKho1O2z6NF9Lviid7Yx9S0bI8aAMAtno3dF2UEVEV6zfqMa/gXqG7eh1pTOqV8 /WRQ3a8I/fQpykT/ufKfAeKaPJpYMGsEHRciclibGPzxnDRCAAs2vHYRp5fOLu13UOUYLxgtk egitZl2NEondC/J01wzf2Qj3ULfCnqdQidxOnCsK+MGEuiPQG33ER8pj1Da+IMk5rG5V/maDh rQgl1eHzMBZX3gD2UwtDXP6ifdmYIR2johoQMSKegtNrmr6d1IjoCQkzFm+v9aMtwTDZpcP9Y oMAmE0Z Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Markus Elfring Date: Sun, 4 Sep 2016 21:01:47 +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 --- arch/x86/kernel/amd_nb.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/arch/x86/kernel/amd_nb.c b/arch/x86/kernel/amd_nb.c index 4fdf623..e2e3e8a 100644 --- a/arch/x86/kernel/amd_nb.c +++ b/arch/x86/kernel/amd_nb.c @@ -226,7 +226,9 @@ static void amd_cache_gart(void) if (!amd_nb_has_feature(AMD_NB_GART)) return; - flush_words = kmalloc(amd_nb_num() * sizeof(u32), GFP_KERNEL); + flush_words = kmalloc_array(amd_nb_num(), + sizeof(*flush_words), + GFP_KERNEL); if (!flush_words) { amd_northbridges.flags &= ~AMD_NB_GART; pr_notice("Cannot initialize GART flush words, GART support disabled\n"); -- 2.9.3