From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933682AbcAMUl5 (ORCPT ); Wed, 13 Jan 2016 15:41:57 -0500 Received: from userp1040.oracle.com ([156.151.31.81]:42685 "EHLO userp1040.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932723AbcAMUl4 (ORCPT ); Wed, 13 Jan 2016 15:41:56 -0500 Date: Wed, 13 Jan 2016 23:41:37 +0300 From: Dan Carpenter To: Felipe Ferreri Tonello Cc: Michal Nazarewicz , Felipe Balbi , Greg Kroah-Hartman , Robert Baldyga , Andrzej Pietrasiewicz , Pawel Szewczyk , linux-kernel@vger.kernel.org Subject: Re: [PATCHv2 1/2] usb: gadget: f_midi: use flexible array member for gmidi_in_port elements Message-ID: <20160113204137.GC4399@mwanda> References: <1452311230-21431-1-git-send-email-mina86@mina86.com> <569696CE.1000707@felipetonello.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <569696CE.1000707@felipetonello.com> User-Agent: Mutt/1.5.21 (2010-09-15) X-Source-IP: aserv0021.oracle.com [141.146.126.233] Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Jan 13, 2016 at 06:26:22PM +0000, Felipe Ferreri Tonello wrote: > > @@ -1115,26 +1112,16 @@ static struct usb_function *f_midi_alloc(struct usb_function_instance *fi) > > } > > > > /* allocate and initialize one new instance */ > > - midi = kzalloc(sizeof(*midi), GFP_KERNEL); > > + midi = kzalloc( > > + sizeof(*midi) + opts->in_ports * sizeof(*midi->in_ports_array), > > + GFP_KERNEL); > > Is there a garantee that the compiler will always use in_ports_array at > the end of the allocated block? > Yes. It's fine. Zero size arrays at the end of a struct are normal. regards, dan carpenter