From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754230AbcICQv2 (ORCPT ); Sat, 3 Sep 2016 12:51:28 -0400 Received: from www62.your-server.de ([213.133.104.62]:45646 "EHLO www62.your-server.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753942AbcICQv0 (ORCPT ); Sat, 3 Sep 2016 12:51:26 -0400 Message-ID: <57CAFF88.2000506@iogearbox.net> Date: Sat, 03 Sep 2016 18:51:20 +0200 From: Daniel Borkmann User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.7.0 MIME-Version: 1.0 To: SF Markus Elfring , sparclinux@vger.kernel.org, Adam Buchbinder , Alexei Starovoitov , "David S. Miller" , Rabin Vincent CC: LKML , kernel-janitors@vger.kernel.org, Julia Lawall , Paolo Bonzini Subject: Re: [PATCH 1/4] sparc: bpf_jit: Use kmalloc_array() in bpf_jit_compile() References: <566ABCD9.1060404@users.sourceforge.net> <259699cf-6fb1-f9e6-f535-fe880a7fa6dc@users.sourceforge.net> In-Reply-To: <259699cf-6fb1-f9e6-f535-fe880a7fa6dc@users.sourceforge.net> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit X-Authenticated-Sender: daniel@iogearbox.net Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 09/03/2016 06:36 PM, SF Markus Elfring wrote: > From: Markus Elfring > Date: Sat, 3 Sep 2016 17:10:20 +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. When you talk about "issue", could you please explain yourself what concrete "issue" you were seeing ?! This particular multiplication here is guaranteed to never overflow, so at best a minor cleanup if you will. (Do you actually have a sparc to test out your changes?) > Signed-off-by: Markus Elfring > --- > arch/sparc/net/bpf_jit_comp.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/arch/sparc/net/bpf_jit_comp.c b/arch/sparc/net/bpf_jit_comp.c > index a6d9204..ced1393 100644 > --- a/arch/sparc/net/bpf_jit_comp.c > +++ b/arch/sparc/net/bpf_jit_comp.c > @@ -372,7 +372,7 @@ void bpf_jit_compile(struct bpf_prog *fp) > if (!bpf_jit_enable) > return; > > - addrs = kmalloc(flen * sizeof(*addrs), GFP_KERNEL); > + addrs = kmalloc_array(flen, sizeof(*addrs), GFP_KERNEL); > if (addrs == NULL) > return; > >