You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by "CV-Bowen (via GitHub)" <gi...@apache.org> on 2023/01/29 11:30:31 UTC

[GitHub] [nuttx] CV-Bowen opened a new pull request, #8339: mm_memalign: avoid two adjacent free nodes situation.

CV-Bowen opened a new pull request, #8339:
URL: https://github.com/apache/nuttx/pull/8339

   ## Summary
   Original m_memalign code assumes the previous node in physical must be ALLOCED, but other thread may free the previous node between mm_malloc() and mm_lock(), and the original code didn't condsider this, which will cause two adjacent free nodes situation and this should not be happened.
   
   This commit will merge the previous node and node if the previous node is free to avoid the situation discribed above.
   
   ## Impact
   memalign
   
   ## Testing
   vela and sim mmtest
   


-- 
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: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [nuttx] CV-Bowen commented on pull request #8339: mm_memalign: avoid two adjacent free nodes situation.

Posted by "CV-Bowen (via GitHub)" <gi...@apache.org>.
CV-Bowen commented on PR #8339:
URL: https://github.com/apache/nuttx/pull/8339#issuecomment-1407937185

   @yamt @masayuki2009 Could you review this patch?


-- 
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: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [nuttx] CV-Bowen commented on a diff in pull request #8339: mm_memalign: avoid two adjacent free nodes situation.

Posted by "CV-Bowen (via GitHub)" <gi...@apache.org>.
CV-Bowen commented on code in PR #8339:
URL: https://github.com/apache/nuttx/pull/8339#discussion_r1090119803


##########
mm/mm_heap/mm_memalign.c:
##########
@@ -146,11 +146,18 @@ FAR void *mm_memalign(FAR struct mm_heap_s *heap, size_t alignment,
     {
       FAR struct mm_allocnode_s *newnode;
       FAR struct mm_allocnode_s *next;
+      FAR struct mm_freenode_s *prev;
       size_t precedingsize;
 
+      /* Mark node free */
+
+      node->preceding &= ~MM_MASK_BIT;
+
       /* Get the node the next node after the allocation. */
 
       next = (FAR struct mm_allocnode_s *)((FAR char *)node + node->size);
+      prev = (FAR struct mm_freenode_s *)
+        ((FAR char *)node - node->preceding);

Review Comment:
   I tried, it's 79 chars, checkpatch.sh report this:
   ```shell
   wangbowen@ubuntu:~/project/community/nuttx_rpmsg_server/nuttx$ tools/checkpatch.sh -g HEAD~...HEAD
   /home/wangbowen/project/community/nuttx_rpmsg_server/nuttx/mm/mm_heap/mm_memalign.c:159:78: error: Long line found
   ```



-- 
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: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [nuttx] xiaoxiang781216 merged pull request #8339: mm_memalign: avoid two adjacent free nodes situation.

Posted by "xiaoxiang781216 (via GitHub)" <gi...@apache.org>.
xiaoxiang781216 merged PR #8339:
URL: https://github.com/apache/nuttx/pull/8339


-- 
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: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [nuttx] acassis commented on a diff in pull request #8339: mm_memalign: avoid two adjacent free nodes situation.

Posted by "acassis (via GitHub)" <gi...@apache.org>.
acassis commented on code in PR #8339:
URL: https://github.com/apache/nuttx/pull/8339#discussion_r1090042107


##########
mm/mm_heap/mm_memalign.c:
##########
@@ -146,11 +146,18 @@ FAR void *mm_memalign(FAR struct mm_heap_s *heap, size_t alignment,
     {
       FAR struct mm_allocnode_s *newnode;
       FAR struct mm_allocnode_s *next;
+      FAR struct mm_freenode_s *prev;
       size_t precedingsize;
 
+      /* Mark node free */
+
+      node->preceding &= ~MM_MASK_BIT;
+
       /* Get the node the next node after the allocation. */
 
       next = (FAR struct mm_allocnode_s *)((FAR char *)node + node->size);
+      prev = (FAR struct mm_freenode_s *)
+        ((FAR char *)node - node->preceding);

Review Comment:
   I think if you out it in a single line it will be smaller than 78 chars



-- 
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: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org