<html><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class="">No, I expect that someone is just being clever. At startup, the USB device generates an init event. The author then brings up everything that is needed.<div class=""><br class=""></div><div class="">Out of the various people I have done a sanity check with, everybody agrees that malloc should not be called in an ISR.</div><div class=""><br class=""></div><div class="">I’ll see what I can do about writing it up and sending a message to ST.</div><div class=""><br class=""></div><div class="">Thanks,</div><div class=""><br class=""></div><div class="">Andrei<br class=""><div class=""><div><br class=""><blockquote type="cite" class=""><div class="">On 2017-December-11, at 19:12, Joel Sherrill <<a href="mailto:joel@rtems.org" class="">joel@rtems.org</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><div dir="ltr" class=""><div class=""><br class=""></div><div class=""><br class=""></div><div class="">See cpukit/libcsupport/src/malloc_deferred.c. It is definitely returning NULL because</div><div class="">you shouldn't malloc from an ISR. malloc() is a non-deterministic operation. I am</div><div class="">surprised that code was designed to do that.</div><div class=""><br class=""></div><div class="">Perhaps this code assumes the USB interrupt is serviced from a thread. The raw</div><div class="">interrupt unblocks a thread to run this code.</div><div class=""><br class=""></div><div class="">--joel</div></div><div class="gmail_extra"><br class=""><div class="gmail_quote">On Mon, Dec 11, 2017 at 6:36 PM, Mr. Andrei Chichak <span dir="ltr" class=""><<a href="mailto:groups@chichak.ca" target="_blank" class="">groups@chichak.ca</a>></span> wrote:<br class=""><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">(sorry if this ended up on the Devel list.)<br class="">
<span class=""><br class="">
I’m working with ST’s HAL USB stack, and to initialize the various structures, they use a USB interrupt as a trigger.<br class="">
<br class="">
In this interrupt,  they malloc some space for a descriptor (504 bytes).<br class="">
<br class="">
The RTEMS malloc always returns 0.<br class="">
<br class="">
Is there a guard against calling malloc in an interrupt context?<br class="">
<br class="">
I managed to get around the problem by doing a static allocation, but I was just wondering.<br class="">
<br class="">
<br class="">
Andrei<br class="">
<br class="">
______________________________<wbr class="">_________________<br class="">
</span>users mailing list<br class="">
<a href="mailto:users@rtems.org" class="">users@rtems.org</a><br class="">
<a href="http://lists.rtems.org/mailman/listinfo/users" rel="noreferrer" target="_blank" class="">http://lists.rtems.org/<wbr class="">mailman/listinfo/users</a></blockquote></div><br class=""></div>
</div></blockquote></div><br class=""></div></div></body></html>