From mboxrd@z Thu Jan 1 00:00:00 1970 From: Matt Fleming Date: Mon, 05 Sep 2016 13:47:41 +0000 Subject: Re: [PATCH] x86/efi: Use kmalloc_array() in efi_call_phys_prolog() Message-Id: <20160905134741.GJ32579@codeblueprint.co.uk> List-Id: References: In-Reply-To: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: SF Markus Elfring Cc: linux-efi-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, x86-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org, "H. Peter Anvin" , Ingo Molnar , Thomas Gleixner , LKML , kernel-janitors-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, Julia Lawall , Paolo Bonzini On Thu, 25 Aug, at 11:40:45AM, SF Markus Elfring wrote: > From: Markus Elfring > Date: Thu, 25 Aug 2016 11:34:03 +0200 > > * A multiplication for the size determination of a memory allocation > indicated that an array data structure should be processed. > Thus reuse 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/platform/efi/efi_64.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/arch/x86/platform/efi/efi_64.c b/arch/x86/platform/efi/efi_64.c > index 677e29e..311022a 100644 > --- a/arch/x86/platform/efi/efi_64.c > +++ b/arch/x86/platform/efi/efi_64.c > @@ -85,7 +85,7 @@ pgd_t * __init efi_call_phys_prolog(void) > early_code_mapping_set_exec(1); > > n_pgds = DIV_ROUND_UP((max_pfn << PAGE_SHIFT), PGDIR_SIZE); > - save_pgd = kmalloc(n_pgds * sizeof(pgd_t), GFP_KERNEL); > + save_pgd = kmalloc_array(n_pgds, sizeof(*save_pgd), GFP_KERNEL); > > for (pgd = 0; pgd < n_pgds; pgd++) { > save_pgd[pgd] = *pgd_offset_k(pgd * PGDIR_SIZE); Thanks, applied with Paolo's Reviewed-by. From mboxrd@z Thu Jan 1 00:00:00 1970 From: Matt Fleming Subject: Re: [PATCH] x86/efi: Use kmalloc_array() in efi_call_phys_prolog() Date: Mon, 5 Sep 2016 14:47:41 +0100 Message-ID: <20160905134741.GJ32579@codeblueprint.co.uk> References: Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Return-path: Content-Disposition: inline In-Reply-To: Sender: linux-efi-owner-u79uwXL29TY76Z2rM5mHXA@public.gmane.org To: SF Markus Elfring Cc: linux-efi-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, x86-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org, "H. Peter Anvin" , Ingo Molnar , Thomas Gleixner , LKML , kernel-janitors-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, Julia Lawall , Paolo Bonzini List-Id: linux-efi@vger.kernel.org On Thu, 25 Aug, at 11:40:45AM, SF Markus Elfring wrote: > From: Markus Elfring > Date: Thu, 25 Aug 2016 11:34:03 +0200 > > * A multiplication for the size determination of a memory allocation > indicated that an array data structure should be processed. > Thus reuse 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/platform/efi/efi_64.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/arch/x86/platform/efi/efi_64.c b/arch/x86/platform/efi/efi_64.c > index 677e29e..311022a 100644 > --- a/arch/x86/platform/efi/efi_64.c > +++ b/arch/x86/platform/efi/efi_64.c > @@ -85,7 +85,7 @@ pgd_t * __init efi_call_phys_prolog(void) > early_code_mapping_set_exec(1); > > n_pgds = DIV_ROUND_UP((max_pfn << PAGE_SHIFT), PGDIR_SIZE); > - save_pgd = kmalloc(n_pgds * sizeof(pgd_t), GFP_KERNEL); > + save_pgd = kmalloc_array(n_pgds, sizeof(*save_pgd), GFP_KERNEL); > > for (pgd = 0; pgd < n_pgds; pgd++) { > save_pgd[pgd] = *pgd_offset_k(pgd * PGDIR_SIZE); Thanks, applied with Paolo's Reviewed-by. From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933207AbcIENrr (ORCPT ); Mon, 5 Sep 2016 09:47:47 -0400 Received: from mail-pf0-f174.google.com ([209.85.192.174]:35451 "EHLO mail-pf0-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932501AbcIENro (ORCPT ); Mon, 5 Sep 2016 09:47:44 -0400 Date: Mon, 5 Sep 2016 14:47:41 +0100 From: Matt Fleming To: SF Markus Elfring Cc: linux-efi@vger.kernel.org, x86@kernel.org, "H. Peter Anvin" , Ingo Molnar , Thomas Gleixner , LKML , kernel-janitors@vger.kernel.org, Julia Lawall , Paolo Bonzini Subject: Re: [PATCH] x86/efi: Use kmalloc_array() in efi_call_phys_prolog() Message-ID: <20160905134741.GJ32579@codeblueprint.co.uk> References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.24+41 (02bc14ed1569) (2015-08-30) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, 25 Aug, at 11:40:45AM, SF Markus Elfring wrote: > From: Markus Elfring > Date: Thu, 25 Aug 2016 11:34:03 +0200 > > * A multiplication for the size determination of a memory allocation > indicated that an array data structure should be processed. > Thus reuse 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/platform/efi/efi_64.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/arch/x86/platform/efi/efi_64.c b/arch/x86/platform/efi/efi_64.c > index 677e29e..311022a 100644 > --- a/arch/x86/platform/efi/efi_64.c > +++ b/arch/x86/platform/efi/efi_64.c > @@ -85,7 +85,7 @@ pgd_t * __init efi_call_phys_prolog(void) > early_code_mapping_set_exec(1); > > n_pgds = DIV_ROUND_UP((max_pfn << PAGE_SHIFT), PGDIR_SIZE); > - save_pgd = kmalloc(n_pgds * sizeof(pgd_t), GFP_KERNEL); > + save_pgd = kmalloc_array(n_pgds, sizeof(*save_pgd), GFP_KERNEL); > > for (pgd = 0; pgd < n_pgds; pgd++) { > save_pgd[pgd] = *pgd_offset_k(pgd * PGDIR_SIZE); Thanks, applied with Paolo's Reviewed-by.