Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix potential memory leak of tev->e_list by reordering list_add befor…
…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. This change ensures the integrity of the event management system by preventing memory leaks associated with tev->e_list during event registration. Signed-off-by: JK Chen <[email protected]>
- Loading branch information