Date: Tue, 15 Oct 2024 17:43:22 GMT From: Osama Abboud <osamaabb@FreeBSD.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org Subject: git: 449496eb28da - main - ena: Fix leaking ifmedia resources on detach Message-ID: <202410151743.49FHhMDw062817@gitrepo.freebsd.org>
next in thread | raw e-mail | index | archive | help
The branch main has been updated by osamaabb: URL: https://cgit.FreeBSD.org/src/commit/?id=449496eb28daec8d5b852fa4be1e337c2957345c commit 449496eb28daec8d5b852fa4be1e337c2957345c Author: Osama Abboud <osamaabb@amazon.com> AuthorDate: 2024-08-07 06:24:22 +0000 Commit: Osama Abboud <osamaabb@FreeBSD.org> CommitDate: 2024-10-15 17:38:32 +0000 ena: Fix leaking ifmedia resources on detach ifmedia_add() allocates an ifmedia_entry during ena_attach. Current code doesn't release this memory during ena_detach() This commit calls ifmedia_removeall() to properly free the allocated memory during ena_detach(). Also, in case ena_attach fails, we need to detach ifmedia which was allocated within ena_setup_ifnet(). This bug was first described in: https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=278100 Reviewed by: zlei Approved by: cperciva (mentor) MFC after: 2 weeks Sponsored by: Amazon, Inc. --- sys/dev/ena/ena.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/sys/dev/ena/ena.c b/sys/dev/ena/ena.c index 28a4d7842306..e9d4530e9085 100644 --- a/sys/dev/ena/ena.c +++ b/sys/dev/ena/ena.c @@ -3981,6 +3981,7 @@ ena_attach(device_t pdev) #ifdef DEV_NETMAP err_detach: ether_ifdetach(adapter->ifp); + ifmedia_removeall(&adapter->media); free(adapter->customer_metrics_array, M_DEVBUF); #endif /* DEV_NETMAP */ err_metrics_buffer_destroy: @@ -4031,6 +4032,8 @@ ena_detach(device_t pdev) ether_ifdetach(adapter->ifp); + ifmedia_removeall(&adapter->media); + /* Stop timer service */ ENA_LOCK_LOCK(); ENA_TIMER_DRAIN(adapter);
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202410151743.49FHhMDw062817>