From nobody Thu Oct 31 16:01:42 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 4XfTJR3SPbz5bwb9; Thu, 31 Oct 2024 16:01:43 +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 "R10" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4XfTJQ599dz4TSK; Thu, 31 Oct 2024 16:01:42 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1730390502; 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=Zz+jl2qu5VgelcCmFecS4auHHyprqk+st0SxCNXgiTc=; b=ZMZX0jwj+lWsdLQ8orqyfTDuY3EQkl9MpoSR0tJIIW/+oyPbGHI0Lm1Ad7IirKiA49RytE df/Ifrv/gvRr6q9dj6446EbhjQDTgfVhoXb0ElCplPYYDK/tk4ugJmGexDBlv9xlSMtsG+ q+h4dkU8H7EJ96hpc9/zK+p81bnQkcFE23xtc0CcY75uUFR8/BXggibujUacMaB3+CnWza lrnYJsFNWfHv9mqfrmcQQmsHKiNX8moh4vJexbx1f6Cs3swCrkZIIllDR15UEXrCh0InhG QHMKsHVUkPmheTrQdvhZ4Kb+24o0GRSMRDvxAtuo5w1mu3DO6F+AqNoZhFruCw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1730390502; 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=Zz+jl2qu5VgelcCmFecS4auHHyprqk+st0SxCNXgiTc=; b=LZGUSnyLlD4UZIl9tdBwBPhpv1vSSUwoP4pBs2+STT2kI7a9s7iW+y76O6o2HFEVJX4YJk xEsWk3dLPig6wWvkpwjcBWm8y0KfDncMDH0yUeYm7DD61qs90DgDWrQd8K9SOV1VSwCUcL NVJLsyi6cH2c0qm4UhM50OD9fIJLs47ctgjECsh20s2qgdyRhxljKphe4+okCuqKPoe7vh q5KoRsP39Tpu14+dL72g171K7+3f6k4VWf9vcDMeUAJ2oRt0MlalkthKi+zAkUXrncSRHV ep5CaEmH7TlApi5KdCbEG0htYaP1xBQ2KqTq4Qh4znFuKdQZ5gk58mgFGZ4WLA== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1730390502; a=rsa-sha256; cv=none; b=B+ECIjGIxtD3QHo8vG21TBac5TZwLmDezSCUymLjwzvUbWC2hQbg5PxGpWasP5iSwIu/x6 y4gs9DRCDNyaEDvCpHdeiuYe5A4F/pXmMsUneTRys5l0gtcMuavvNJwtw1R7xQc1N+/KBJ 7YCm+VoNpr8+s5rQKQZ0ib68mUxbf6tXPF8Iwl77lg9ozYTfge0ZQEXlo7RH1C0xiL+AX+ VJJykTaqTMWOikgIKxhpFb3/WnspWM0Lc/LO62Qt/R3o5kbzQYi70emoBUildcSBFNnQTT 1bEeVJff6Ew/p0ytYB7k3qVfLqkBJZZlRVShmFyc62jJNebQcIaYvz8DuJEVyw== 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 4XfTJQ4jfFzjXQ; Thu, 31 Oct 2024 16:01:42 +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 49VG1g4D073478; Thu, 31 Oct 2024 16:01:42 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 49VG1gnu073474; Thu, 31 Oct 2024 16:01:42 GMT (envelope-from git) Date: Thu, 31 Oct 2024 16:01:42 GMT Message-Id: <202410311601.49VG1gnu073474@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Osama Abboud Subject: git: 7a39823d8e53 - stable/14 - 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/stable/14 X-Git-Reftype: branch X-Git-Commit: 7a39823d8e53788b2ee38d908a16d2c312c6afe9 Auto-Submitted: auto-generated The branch stable/14 has been updated by osamaabb: URL: https://cgit.FreeBSD.org/src/commit/?id=7a39823d8e53788b2ee38d908a16d2c312c6afe9 commit 7a39823d8e53788b2ee38d908a16d2c312c6afe9 Author: Osama Abboud AuthorDate: 2024-08-07 06:24:22 +0000 Commit: Osama Abboud CommitDate: 2024-10-31 14:54:12 +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) Sponsored by: Amazon, Inc. (cherry picked from commit 449496eb28daec8d5b852fa4be1e337c2957345c) --- 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);