Is there is recommandations, hints on do-do-not-do when ISR requires to allocate dynamic memory?
Almost every OS and bare metal library prohibit such things in an ISR and for very good reason. If you need to fill in a buffer or something in an ISR, make sure it is allocated beforehand and the address accessible to the ISR.
Problems:
1. What do you do in case of allocation failure?
2. ISRs are supposed to do two, and only two, thing: Stop the hardware from interrupting and schedule post processing in normal context. To do anything else risks severely degrading the performance and reliability of the system.
3. Most calls, like allocating memory, requires some sort of process context. An ISR has no such context, unless it is bare metal.
Potential solutions:
1. Rotating buffers.
2. Pre-allocated single buffer
3. Allocate and copy data in post processing AFTER the HW interrupt has been acknowledged and system interrupts reenabled.
One more solution:
Process the data inside the interrupt, in case processing the data will be quick.