[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <20201206160709.GA1212872@rowland.harvard.edu>
Date: Sun, 6 Dec 2020 11:07:09 -0500
From: Alan Stern <stern@...land.harvard.edu>
To: Bui Quang Minh <minhquangbui99@...il.com>
Cc: Felipe Balbi <balbi@...nel.org>,
Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
Corentin Labbe <clabbe@...libre.com>,
Jules Irenge <jbi.octave@...il.com>,
Andrey Konovalov <andreyknvl@...il.com>,
linux-usb@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH] USB: dummy-hcd: Fix uninitialized array use in init()
On Sun, Dec 06, 2020 at 06:24:05PM +0700, Bui Quang Minh wrote:
> On Sat, Dec 05, 2020 at 10:15:11AM -0500, Alan Stern wrote:
> > On Sat, Dec 05, 2020 at 07:47:01PM +0700, Minh Bùi Quang wrote:
> > > Vào Th 6, 4 thg 12, 2020 vào lúc 23:12 Alan Stern
> > > <stern@...land.harvard.edu> đã viết:
> > > > Does this initialization end up using less memory than an explicit
> > > > memset() call?
> > >
> > > You mean speed?
> >
> > No, I mean memory space.
> >
> > A memset call requires a certain amount of instruction space (to push
> > the arguments and make the call) but no static data space.
> > Initialization requires some instruction space (to copy the data) and
> > static data space as well (to hold the data that is to be copied).
> >
> > Alan Stern
> >
>
> Thank you for your clarification, I didn't think about it before.
>
> As I check when compiling the code, with MAX_NUM_UDC=32 the initialization
> becomes
>
> xor eax,eax
> mov ecx,0x40
> rep stos DWORD PTR es:[rdi],eax
>
> With MAX_NUM_UDC=2, the initialization becomes
>
> mov QWORD PTR [rbp-0x30],0x0
> mov QWORD PTR [rbp-0x28],0x0
>
> As I see, initialization does not require additional static data space.
> Am I right?
Ah, okay, good. I didn't realize the compiler was smart enough to do
this. Thanks for checking.
Alan Stern
Powered by blists - more mailing lists