From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753367AbcHZT6M (ORCPT ); Fri, 26 Aug 2016 15:58:12 -0400 Received: from mail2-relais-roc.national.inria.fr ([192.134.164.83]:12119 "EHLO mail2-relais-roc.national.inria.fr" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751485AbcHZT6I (ORCPT ); Fri, 26 Aug 2016 15:58:08 -0400 X-IronPort-AV: E=Sophos;i="5.28,582,1464645600"; d="scan'208";a="234208790" Date: Fri, 26 Aug 2016 15:57:34 -0400 (EDT) From: Julia Lawall X-X-Sender: jll@hadrien To: SF Markus Elfring cc: linux-ia64@vger.kernel.org, Fenghua Yu , Tony Luck , LKML , kernel-janitors@vger.kernel.org, Paolo Bonzini Subject: Re: [PATCH 1/5] IA64-IRQ: Use kmalloc_array() in sn_irq_lh_init() In-Reply-To: <2e046b40-1c8e-717f-68b1-534c3125724c@users.sourceforge.net> Message-ID: References: <349bbfb4-bada-628e-2981-ca2a315299fc@users.sourceforge.net> <2e046b40-1c8e-717f-68b1-534c3125724c@users.sourceforge.net> User-Agent: Alpine 2.10 (DEB 1266 2009-07-14) MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, 26 Aug 2016, SF Markus Elfring wrote: > From: Markus Elfring > Date: Fri, 26 Aug 2016 18:32:53 +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 data structures by pointer dereferences > to make the corresponding size determination a bit safer according to > the Linux coding style convention. > > Signed-off-by: Markus Elfring > --- > arch/ia64/sn/kernel/irq.c | 4 ++-- > 1 file changed, 2 insertions(+), 2 deletions(-) > > diff --git a/arch/ia64/sn/kernel/irq.c b/arch/ia64/sn/kernel/irq.c > index 85d0951..c7f9eea 100644 > --- a/arch/ia64/sn/kernel/irq.c > +++ b/arch/ia64/sn/kernel/irq.c > @@ -474,12 +474,12 @@ void __init sn_irq_lh_init(void) > { > int i; > > - sn_irq_lh = kmalloc(sizeof(struct list_head *) * NR_IRQS, GFP_KERNEL); > + sn_irq_lh = kmalloc_array(NR_IRQS, sizeof(*sn_irq_lh), GFP_KERNEL); > if (!sn_irq_lh) > panic("SN PCI INIT: Failed to allocate memory for PCI init\n"); > > for (i = 0; i < NR_IRQS; i++) { > - sn_irq_lh[i] = kmalloc(sizeof(struct list_head), GFP_KERNEL); > + sn_irq_lh[i] = kmalloc(*sn_irq_lh[i], GFP_KERNEL); Did a sizeof get lost here? julia > if (!sn_irq_lh[i]) > panic("SN PCI INIT: Failed IRQ memory allocation\n"); > > -- > 2.9.3 > > -- > To unsubscribe from this list: send the line "unsubscribe kernel-janitors" in > the body of a message to majordomo@vger.kernel.org > More majordomo info at http://vger.kernel.org/majordomo-info.html >