Fix potential memory leak of tev->e_list by reordering list_add before epoll_ctl#66
Open
jkchen1095 wants to merge 1 commit intofujita:masterfrom
Open
Fix potential memory leak of tev->e_list by reordering list_add before epoll_ctl#66jkchen1095 wants to merge 1 commit intofujita:masterfrom
jkchen1095 wants to merge 1 commit intofujita:masterfrom
Conversation
1ccb178 to
e84dc5d
Compare
a2f404a to
8a41c08
Compare
…e epoll_ctl This commit addresses a potential memory leak in tgt_event_add related to tev->e_list. Previously, epoll_ctl(EPOLL_CTL_ADD) was called before list_add. This sequence could lead to a race condition where the epoll event is registered and immediately triggered, leading to EPOLL_CTL_DEL and list_del being called before list_add, resulting in the event being removed from epoll but never added to the list, causing a memory leak after calling list_add (Because no one will call list_del to remove this tev->e_list anymore). To prevent this, list_add is now called before epoll_ctl(EPOLL_CTL_ADD). This ensures that the tev->e_list is added to the list before any epoll events can be triggered, allowing proper cleanup by list_del in case of an early EPOLL_CTL_DEL. Signed-off-by: JK Chen <jk.chen1095@gmail.com>
Owner
|
One thread calls tgt_event_add() and another thread calls tgt_event_del()? It's possible? |
Author
|
Hi fujita |
Owner
|
If we need to think about multi threads, there are many other races. So I don't think that fixing one place makes sense. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This commit addresses a potential memory leak in
tgt_event_addrelated totev->e_list. Previously,epoll_ctl(EPOLL_CTL_ADD)was called beforelist_add. This sequence could lead to a race condition where the epoll eventis registered and immediately triggered, leading to
EPOLL_CTL_DELandlist_delbeing called beforelist_add, resulting in the event being removedfrom epoll but never added to the list, causing a memory leak after calling
list_add(Because no one will calllist_delto remove thistev->e_listanymore).To prevent this,
list_addis now called beforeepoll_ctl(EPOLL_CTL_ADD).This ensures that the
tev->e_listis added to the list before anyepoll events can be triggered, allowing proper cleanup by
list_delin caseof an early
EPOLL_CTL_DEL.