Revert "This patch prevent heap corruption as in below case."

This solution to the problem noted by EunBong Song results in major memory fragmentation and and out-of-memory conditions on the PX4 platform.  On that platform the lower priority work queue is very low priority and essentially never runs when the system is busy.  As a result, the systems gets slowly starved of memory until failures and bad behaviors begin to occur.

This is an addition patch coming later to result the original problem in a different way that does not have cause memory starvation.

This reverts commit 91aa26774b.
This commit is contained in:
Gregory Nutt 2018-12-20 10:11:36 -06:00
parent 9c5d0003aa
commit 9d1c845dcc

View File

@ -85,6 +85,8 @@ void sched_ufree(FAR void *address)
* must have exclusive access to the memory manager to do this.
*/
if (up_interrupt_context() || kumm_trysemaphore() != 0)
{
irqstate_t flags;
/* Yes.. Make sure that this is not a attempt to free kernel memory
@ -106,6 +108,14 @@ void sched_ufree(FAR void *address)
sched_signal_free();
leave_critical_section(flags);
}
else
{
/* No.. just deallocate the memory now. */
kumm_free(address);
kumm_givesemaphore();
}
#endif
}
@ -119,6 +129,8 @@ void sched_kfree(FAR void *address)
* must have exclusive access to the memory manager to do this.
*/
if (up_interrupt_context() || kmm_trysemaphore() != 0)
{
/* Yes.. Make sure that this is not a attempt to free user memory
* using the kernel deallocator.
*/
@ -135,6 +147,14 @@ void sched_kfree(FAR void *address)
sched_signal_free();
leave_critical_section(flags);
}
else
{
/* No.. just deallocate the memory now. */
kmm_free(address);
kmm_givesemaphore();
}
}
#endif