Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

mm_memalign: avoid two adjacent free nodes situation. #8339

Merged
merged 1 commit into from
Jan 30, 2023

Conversation

CV-Bowen
Copy link
Contributor

@CV-Bowen CV-Bowen commented Jan 29, 2023

Summary

Original mm_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

Original 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.

Signed-off-by: wangbowen6 <wangbowen6@xiaomi.com>
Comment on lines +159 to +160
prev = (FAR struct mm_freenode_s *)
((FAR char *)node - node->preceding);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tried, it's 79 chars, checkpatch.sh report this:

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

@CV-Bowen
Copy link
Contributor Author

@yamt @masayuki2009 Could you review this patch?

@xiaoxiang781216 xiaoxiang781216 merged commit 81d37d0 into apache:master Jan 30, 2023
@CV-Bowen CV-Bowen deleted the memalign branch May 27, 2023 07:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants