From patchwork Thu Aug 25 11:30:48 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: SF Markus Elfring X-Patchwork-Id: 9299259 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id D47A260459 for ; Thu, 25 Aug 2016 11:33:11 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C4F1B2927F for ; Thu, 25 Aug 2016 11:33:11 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B972F29282; Thu, 25 Aug 2016 11:33:11 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.2 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 512752927F for ; Thu, 25 Aug 2016 11:33:11 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bcssH-0000Zl-10; Thu, 25 Aug 2016 11:31:09 +0000 Received: from mail6.bemta5.messagelabs.com ([195.245.231.135]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bcssF-0000Ze-Nb for xen-devel@lists.xenproject.org; Thu, 25 Aug 2016 11:31:07 +0000 Received: from [85.158.139.211] by server-15.bemta-5.messagelabs.com id BB/5F-12460-AF6DEB75; Thu, 25 Aug 2016 11:31:06 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFprMIsWRWlGSWpSXmKPExsVy5bEgt+6va/v CDU6vl7T4vmUykwOjx+EPV1gCGKNYM/OS8isSWDMebpUvWMtZ0dY8mbGBsYmji5GLQ0hgLqPE nW29TCCOiMAKJolLbU/AHGaBHYwSi9YcZOti5ORgEzCX6F37mQXEFhbwlXiwo5EdxOYV8JCY/ /M3mM0ioCrx4tROMFtUIFRixZsTbBA1ghInZz4B62UWUJf4M+8SM4QtL7H97RxmkGUSAp8ZJZ Yt+AvWLCHQxy7R/EtzAiPvLCT9s5D0z0LSv4CReRWjenFqUVlqka65XlJRZnpGSW5iZo6uoYG pXm5qcXFiempOYlKxXnJ+7iZGYGAxAMEOxmOTnQ8xSnIwKYnyaq/YFy7El5SfUpmRWJwRX1Sa k1p8iFGGg0NJgtfmKlBOsCg1PbUiLTMHGOIwaQkOHiUR3tMgad7igsTc4sx0iNQpRkUpcV53k IQASCKjNA+uDRZXlxhlpYR5GYEOEeIpSC3KzSxBlX/FKM7BqCTMOxdkCk9mXgnc9FdAi5mAFr fc3w2yuCQRISXVwCha0TxlUuDeNtfQfqmZRfKrJaY78ud1CmXfa7kmPNFTa51lYF0JW2LXFaH SjzNnet9J1Q/XsktSVbz9IVSRy+pHgpnHIsVbGurvS/6ev/r2We4ikSLrrg9FLHEr9y7xmS6z 2m+zJFuOSkXK5K//Axe2dXlUmmg98XfcmRCh8M67SH6Dz215JZbijERDLeai4kQAooETS6YCA AA= X-Env-Sender: elfring@users.sourceforge.net X-Msg-Ref: server-4.tower-206.messagelabs.com!1472124666!56274174!1 X-Originating-IP: [212.227.17.11] X-SpamReason: No, hits=0.0 required=7.0 tests=sa_preprocessor: QmFkIElQOiAyMTIuMjI3LjE3LjExID0+IDE4NTg2\n,sa_preprocessor: QmFkIElQOiAyMTIuMjI3LjE3LjExID0+IDE4NTg2\n X-StarScan-Received: X-StarScan-Version: 8.84; banners=-,-,- X-VirusChecked: Checked Received: (qmail 35422 invoked from network); 25 Aug 2016 11:31:06 -0000 Received: from mout.web.de (HELO mout.web.de) (212.227.17.11) by server-4.tower-206.messagelabs.com with DHE-RSA-AES256-GCM-SHA384 encrypted SMTP; 25 Aug 2016 11:31:06 -0000 Received: from [192.168.1.3] ([78.49.16.254]) by smtp.web.de (mrweb102) with ESMTPSA (Nemesis) id 0Lba7D-1asJdP2G67-00lHb2; Thu, 25 Aug 2016 13:30:52 +0200 To: xen-devel@lists.xenproject.org, x86@kernel.org, Boris Ostrovsky , David Vrabel , "H. Peter Anvin" , Ingo Molnar , =?UTF-8?B?SsO8cmdlbiBHcm/Dnw==?= , Thomas Gleixner From: SF Markus Elfring Message-ID: <8a04e3d1-2756-9e3a-e5ba-f5d0e6495df7@users.sourceforge.net> Date: Thu, 25 Aug 2016 13:30:48 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.2 MIME-Version: 1.0 X-Provags-ID: V03:K0:uTi8zCxkz8SmXVgr5tX3yTYfAgGsyxwZyGzj2iW9GBX3JHQHCUm fPTcLjirYdH+CogariokjskQZqTXZP3ac0sHAbw6M7zmk9m5M/cxKgTNbhlujltZkqFf7vZ QWdkFkEETN+SjpriNa0PB1Lgxj7tdADws9NyD4PMaYkqbyiXvj2MR1xhAnitPGK6tVTwZ68 FG3PCgBsSfx4zCkulwVlw== X-UI-Out-Filterresults: notjunk:1; V01:K0:dF6to/j8z2A=:fi4azY/1NximMc9wotF2OU pAj22p5E0x7ZXosKhlZ6csaGOTxd58vsQlR3y2Q2sNGB7SRpBhOuBMzGylZiEqaMvb76dWrZk bHE7VrcbPW36yqRxAbjU2A039Q8zLHUsw7V9KFLYe4k+SKDt86QCM+YS+Hyoc9FnAaVJdspEz 8iK9VmSgrVnMTbxTARVD0L4pYbopZnszX3u7V0O8Bs0s40DhCZGexbcY28CmunHmEeU8ijqF6 xNxoqgf5bOcr8Apk7pJ46UtV/BDYy9MhOQgVAQcRipExKaPksFHd7NkDpRk83/GwQRo/nD1r1 LKtV8sAX0NbhIi1LHCnHnRjY7QP2a21ZbCZ24mgtI/vz/o3qjHyA39NSpv4lvX80BbDXbxghf n247NcPEYA6JunLEpaKePrEcRENY0U3vwh85oi5cGOMag0/ieSWKV1o2Azd+emJ1OE4qBIABR G9jATmfTKHOfN1lfU4lFyx4EmUZt5JaNdoC2UkugFWGEymJQ7v8Nhpjn/I7NFKg5Z/SlzTUGE b2Qj6S5kOCr+h08BpejqCiaFX77WZvOPP+941LJgJLKQmdS9L1V1U2YW1PGDhSY47ECAgZ4rG a42HGGZ0gsoEmuirrjPHoxrGEwUD0YkWem0X2Cfu8WzeaT7oI0tvTLFY2owydoOid6it6YEeC 3wYh4lI1FSi0XnRGa7IW321BuaWL8p4Y2aPVXbZzMVkLvP1qRZJ+k21s7gHmdYoIbv+21y3C+ eKL8krAYJcab2390wE8UxdATXyIXajMraklyv+SRoLkxDGnHcw8uM9KBxZ6X9V67T25rSBmaY yeQzAKX Cc: Julia Lawall , "kernel-janitors@vger.kernel.org" , LKML , Paolo Bonzini Subject: [Xen-devel] [PATCH] xen/grant-table: Use kmalloc_array() in arch_gnttab_valloc() X-BeenThere: xen-devel@lists.xen.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xen.org Sender: "Xen-devel" X-Virus-Scanned: ClamAV using ClamSMTP From: Markus Elfring Date: Thu, 25 Aug 2016 13:23:06 +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 Reviewed-by: Juergen Gross --- arch/x86/xen/grant-table.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/x86/xen/grant-table.c b/arch/x86/xen/grant-table.c index de4144c..809b6c8 100644 --- a/arch/x86/xen/grant-table.c +++ b/arch/x86/xen/grant-table.c @@ -89,7 +89,7 @@ void arch_gnttab_unmap(void *shared, unsigned long nr_gframes) static int arch_gnttab_valloc(struct gnttab_vm_area *area, unsigned nr_frames) { - area->ptes = kmalloc(sizeof(pte_t *) * nr_frames, GFP_KERNEL); + area->ptes = kmalloc_array(nr_frames, sizeof(*area->ptes), GFP_KERNEL); if (area->ptes == NULL) return -ENOMEM;