[U-Boot] [PATCH 17/17] spi: Avoid using malloc() in a critical function
Simon Glass
sjg at chromium.org
Mon May 20 20:51:09 UTC 2019
Hi Urja,
On Mon, 20 May 2019 at 10:36, Urja Rannikko <urjaman at gmail.com> wrote:
>
> Hi Simon,
>
> On Mon, May 20, 2019 at 7:09 PM Simon Glass <sjg at chromium.org> wrote:
> >
> > Hi Urja,
> <snip>
> > Is it possible to add a build-time assert for this somewhere?
> I'm not sure, you'd need to check every user of these operations - i
> was going to suggest just bailing out with an error code or a runtime
> assert, and going through the users of the SPI_MEM_OP macros to make
> sure there's no surprises.
I think bailing out with -ENOSPC would be fine.
> >
> > Is VLA very large array? How large is very large?
> VLA as in variable length array, the C feature you're using above.
> For a reference of sorts, more on VLAs and the kernel, which got rid
> of them in 4.20: https://lwn.net/Articles/749064/
OK I see. My only concern with variable-length arrays is when the
length is unbounded. If we had a run-time check beforehand (size < 100
for example), then I suppose it would be OK. It seems like in this
case we don't need one though.
>
> > I think the stack is much better place than a fixed buffer for
> > something only 8 bytes in size.
> Yes.
Regards,
Simon
More information about the U-Boot
mailing list