From mboxrd@z Thu Jan 1 00:00:00 1970 From: Ido Schimmel Subject: Re: [PATCH] mlxsw: spectrum_acl_bloom_filter: use struct_size() in kzalloc() Date: Mon, 24 Dec 2018 09:38:38 +0200 Message-ID: <20181224073838.GA11051@splinter> References: <20181224052741.GA22098@embeddedor.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Cc: Jiri Pirko , Ido Schimmel , "David S. Miller" , netdev@vger.kernel.org, linux-kernel@vger.kernel.org To: "Gustavo A. R. Silva" Return-path: Received: from out1-smtp.messagingengine.com ([66.111.4.25]:50819 "EHLO out1-smtp.messagingengine.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726702AbeLXHin (ORCPT ); Mon, 24 Dec 2018 02:38:43 -0500 Content-Disposition: inline In-Reply-To: <20181224052741.GA22098@embeddedor.com> Sender: netdev-owner@vger.kernel.org List-ID: On Sun, Dec 23, 2018 at 11:27:41PM -0600, Gustavo A. R. Silva wrote: > One of the more common cases of allocation size calculations is finding > the size of a structure that has a zero-sized array at the end, along > with memory for some number of elements for that array. For example: > > struct foo { > int stuff; > void *entry[]; > }; > > instance = kzalloc(sizeof(struct foo) + sizeof(void *) * count, GFP_KERNEL); > > Instead of leaving these open-coded and prone to type mistakes, we can > now use the new struct_size() helper: > > instance = kzalloc(struct_size(instance, entry, count), GFP_KERNEL); > > This issue was detected with the help of Coccinelle. > > Signed-off-by: Gustavo A. R. Silva Reviewed-by: Ido Schimmel But net-next is closed (http://vger.kernel.org/~davem/net-next.html) and this isn't a bug fix. Can you please re-submit when net-next opens again? Alternatively, I can apply the patch to my mlxsw queue and submit in your stead. Let me know what you prefer. Thanks!