From nobody Tue Oct 15 17:43:22 2024 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4XShK66vjXz5Ylyv; Tue, 15 Oct 2024 17:43:22 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R11" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4XShK637fpz4ZmX; Tue, 15 Oct 2024 17:43:22 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1729014202; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=AkhFDXHctWnWjkAOWhNwLO8W0LN3Le96Rnmx2M1F+lk=; b=MGpuQ856kjvZmnnYx2vfLbfv75HI3noBbM+9AOpIUyr2CuLIeabzwUbuGjh/kleiAlFko7 EkPGHwZfV8GeAK1QUW1lMyGpn+W725XmcGV3BFYdYKJknVwOK5NnrBJdUH/XtFTnH8mu9y zZ+yxbuHVN3uPPfn3weghPoWOEiLE23Sm42tPaYwzQA8AZ6zO9TYutZaIMRe/KDxTXM9BX OY+tyZK5sf1Txl3SE0U7RFc7UM1cWHsC1UZscfMeIN7jhZOkBnr2kzVC5h7rQFbtUvMjrj EdPPOAZO/XrsngL3Gacsm3u5syZlhe7YRpBmUv31xXTPknWXHCHFpedNblF3aA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1729014202; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=AkhFDXHctWnWjkAOWhNwLO8W0LN3Le96Rnmx2M1F+lk=; b=r8p1SHqETHucsichervHx8rGp3gVqbv6tv8t+mnf/YP7V3kBp7a11LEyaUW9UYwDkcV+lZ pkGRGNAQAoKKurc1bga2wKUwWZbYOu/zhiIkuc9C26UIBT6SURe01j8FQr9FRUH1EH7y+R L+WInLFZ39hV9GUIEZ2qX42uKwcemFhu8uT/mK4CQtw6g/bo+CsKMZ7NWBMx+rpHrZmpDA rW5Xo/oH/JCADanAWCqobjcISK/UdAUKhHEMkrbJWjLPSR9SBMFT2parsGAV3M0cCJgu4z +0ycg7qM4F3hgvBxQ21Wuo9S0Ppk5SFqeHXnwAtMUGkz0MdS/g2r91uYOKQ1jQ== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1729014202; a=rsa-sha256; cv=none; b=R+OD69MO8674LxHTX25Vd2Lj34/N3RnOSlyFm0TkFnpQgW8jnlnN6gWgqPiICZzGRGg+H/ Pl4EVB+GF2F+8lJqcreqWIwAjksunhzcIMT8TgyJBNkHvkpvZt/FR6nR3Wz4lwOpxpie2h 4ZcyYunUoupk9ezFpHcS5Rib0XWUbMrjFiLa7oGYJ+IR/uQRSOHk5JuOl9Ai0ee0d1kkBY jwQe/o5yDGifKwRdpB4GDRnQdUW6PE3+5onLoE2TYP3vajf51RAhW5pbTUsrLTOWpFOLDW e/eP+kifUhXkdepZRQh2MX38DvLxs5X3Q4GST++y62R619hjEtImm7tnxdfrcA== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4XShK62ggczXXZ; Tue, 15 Oct 2024 17:43:22 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.18.1/8.18.1) with ESMTP id 49FHhMWL062820; Tue, 15 Oct 2024 17:43:22 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 49FHhMDw062817; Tue, 15 Oct 2024 17:43:22 GMT (envelope-from git) Date: Tue, 15 Oct 2024 17:43:22 GMT Message-Id: <202410151743.49FHhMDw062817@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Osama Abboud Subject: git: 449496eb28da - main - ena: Fix leaking ifmedia resources on detach List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-all@freebsd.org Sender: owner-dev-commits-src-all@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: osamaabb X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 449496eb28daec8d5b852fa4be1e337c2957345c Auto-Submitted: auto-generated The branch main has been updated by osamaabb: URL: https://cgit.FreeBSD.org/src/commit/?id=449496eb28daec8d5b852fa4be1e337c2957345c commit 449496eb28daec8d5b852fa4be1e337c2957345c Author: Osama Abboud AuthorDate: 2024-08-07 06:24:22 +0000 Commit: Osama Abboud 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);