[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20160113204137.GC4399@mwanda>
Date: Wed, 13 Jan 2016 23:41:37 +0300
From: Dan Carpenter <dan.carpenter@...cle.com>
To: Felipe Ferreri Tonello <eu@...ipetonello.com>
Cc: Michal Nazarewicz <mina86@...a86.com>, Felipe Balbi <balbi@...com>,
Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
Robert Baldyga <r.baldyga@...sung.com>,
Andrzej Pietrasiewicz <andrzej.p@...sung.com>,
Pawel Szewczyk <p.szewczyk@...sung.com>,
linux-kernel@...r.kernel.org
Subject: Re: [PATCHv2 1/2] usb: gadget: f_midi: use flexible array member for
gmidi_in_port elements
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
Powered by blists - more mailing lists