-
Notifications
You must be signed in to change notification settings - Fork 349
Fix memory leaks with zephyr native drivers #6540
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
Conversation
Free the memory allocated for DMA channels when the ref count is 0 when using native zephyr drivers. Signed-off-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
Return NULL when dma_init() fails. Signed-off-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
This prevents memory leaks during repeated PCM start/stop tests. Signed-off-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
kv2019i
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Excellent!
| if (--dma->sref == 0) { | ||
| rfree(dma->chan); | ||
| dma->chan = NULL; | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Without this, we lose one "dma->chan = rzalloc(SOF_MEM_ZONE_RUNTIME_SHARED" worth of memory whenever sref goes to 1->0 and back.
juimonen
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes tests work now, nice!
aborisovich
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great find but is really using goto statement mandatory?
It is commonly known fact that this is not a clean code solution...
In fact, it is one of the classical examples of bad code layout. There are too many books written about it,
|
@aborisovich wrote:
Goto usage is pretty widespread in Linux kernel, but only for very specific usage/patterns. I think this falls to one of the well accepted patterns where goto is used to jump to error handler (kind of poor man's exception handler) to make it more explicit that locks are released correctly. |
|
Still 01.org trouble, checked the pr-device-test results offline and they are good (a few DUTs unavailable for the run, but we have test results with similar configurations that pass). Proceeding with merge. |
Free the memory allocated for DMA channels when the ref count is 0 and the DMA block config during DAI reset when using natize zephyr drivers to prevent memory leaks seen during stress tests
Fixes #6535