casaroli commented on code in PR #21439:
URL: https://github.com/apache/nuttx/pull/21439#discussion_r4467345446


##########
fs/inode/fs_files.c:
##########
@@ -175,6 +180,15 @@ static int fdlist_extend(FAR struct fdlist *list, size_t 
row)
       return OK;
     }
 
+  /* Release the buffers we allocated for any rows that the current list
+   * already supplies (its pointers will be copied in below).
+   */
+
+  for (j = orig_rows; j < i && j < list->fl_rows; j++)
+    {
+      fs_heap_free(fds[j]);

Review Comment:
   `fs_heap_free()` runs here with `fl_lock` held and interrupts off. It ends 
in `mm_lock()` -> `nxmutex_lock()`, which can sleep, and `spinlock.h` forbids 
that under `spin_lock_irqsave`; the other frees in this function drop the lock 
first.
   
   Fix: when `list->fl_rows != orig_rows`, unlock, free `fds` and all our rows, 
and call `fdlist_extend(list, row)` again (it returns 0 if the list already has 
`row` rows).



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to