fs/procfs/stat: use heap 0 indexed region for Idle Task
Idle task's stack pointer is not in the heap. So that mm_get_heap with idle task's stack ptr returns NULL.
For getting idle task's heap information, called mm_get_heap_with_index(0).
@@ -384,8 +384,17 @@ static ssize_t proc_entry_stat(FAR struct proc_file_s *procfile, FAR struct tcb_
curr_heap = -1;
peak_heap = -1;
#ifdef CONFIG_DEBUG_MM_HEAPINFO
- hash_pid = PIDHASH(tcb->pid);
+ if (tcb->pid == 0) {
+ /* Idle task normally uses heap with index 0. */
+ heap = mm_get_heap_with_index(0);
+ } else {
heap = mm_get_heap(tcb->stack_alloc_ptr);
+ }
+ if (heap == NULL) {
+ return -1;
+ }
+
+ hash_pid = PIDHASH(tcb->pid);
if (heap->alloc_list[hash_pid].pid == tcb->pid) {
curr_heap = heap->alloc_list[hash_pid].curr_alloc_size;
peak_heap = heap->alloc_list[hash_pid].peak_alloc_size;
