From nobody Thu Oct 31 16:00:16 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 4XfTGm6xLwz5bwnn; Thu, 31 Oct 2024 16:00:16 +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 4XfTGm472vz4PZ5; Thu, 31 Oct 2024 16:00:16 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1730390416; 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=KEGNarfgp8WvEsMYRuRjxSbA1O9IVwdfuUYGUUrjbEc=; b=Nme/fjAVnW2pYrlQRUIvzC1j3HzHkhBPUn11iJS35XoXnAI7JhVzpdvEX3ciLso/Qx64QO 9xNPOPIFMHCMyppfhmv4KvpXlKmWYv6GI/P9FFfa1dLeHPYyzu/prpY+VccbBbBqznwe67 ESqJG4knPKB2br16eiegU6zuJOxPiANO4e3IcWPhppmBq8PpthIISndRb/ch7X9UW/fTqP DMLbhmDaVt6f5h73peMrL3eGCBojOHX2xbCCsF2Al9b2hd8V8bFRnNUeNtuMlXNAU5hSTO YEfInLU3/l320M6xfhPA4SdXgurDXqlpt7pNAueBV5nyg0Ezg59rvzKIjxYQCg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1730390416; 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=KEGNarfgp8WvEsMYRuRjxSbA1O9IVwdfuUYGUUrjbEc=; b=b82UICt51E7zpUqPfv5N0SmDSt1GKBJAHVYs22NGOb3LVuNusEo2n44DnS4wgL5Q5U18Dg 1yOb/qoO48DkS0zaC+1H2wTePu1S8JBAAS8nTSoAUgyF9XD38Lb8Sub6okLil5/fN/huvr mMTIen8AuUsBDui32IhH3m8URskroTntjVoGOQIenbX2WlQymDZAzpTgyIqOoS8ykNqhC2 jNYy44UxOXw9oBD+HQZKBzLkD3jo2UyM7kWqsVmTDLhHvSQkim1NGzkpllp6uHSiNZAhp9 T8Mqah7DmNFdhNoUELrOiKXydZ4RvXRcr1uy4lIgtEhbtxQS/3Do40GRQ5Q8GA== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1730390416; a=rsa-sha256; cv=none; b=DgCQO7SXogKr2aP/tI01lr8BC9HtLL+hVwPzkglsZhF8KIwlZga/zq5W8ia5DGxj6WbwtP Je+OahmIAzbAcKAFAzF6kfUVIHPD6elK2AdnDRTR7JrQg3mEb1DNW2Fvu1f8bCDJPQaIAt AzFjQX/COyv2NZ0Ktunw7BoTrdFzZDPdArC52GxsoJMF0e+d6jFU4mMO9ojujDJ+vEH1f1 z9LlNZqRcQyBMJuZwdEhfIi2OW0Yc5TZiNo/zgDg4gva0issJVWarziOIR7SHma7GqeWaK dClVmmY2BqagejYLlLx026E3izXQh6M4Y8durgmhrvle9dedWIi+TlLB1xNRtQ== 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 4XfTGm3hJBzjV9; Thu, 31 Oct 2024 16:00:16 +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 49VG0GQP066305; Thu, 31 Oct 2024 16:00:16 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 49VG0GT4066296; Thu, 31 Oct 2024 16:00:16 GMT (envelope-from git) Date: Thu, 31 Oct 2024 16:00:16 GMT Message-Id: <202410311600.49VG0GT4066296@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: db775f50e947 - stable/13 - 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/13 X-Git-Reftype: branch X-Git-Commit: db775f50e94744cfedd1f15e3aa5152ab1fbdcde Auto-Submitted: auto-generated The branch stable/13 has been updated by osamaabb: URL: https://cgit.FreeBSD.org/src/commit/?id=db775f50e94744cfedd1f15e3aa5152ab1fbdcde commit db775f50e94744cfedd1f15e3aa5152ab1fbdcde Author: Osama Abboud AuthorDate: 2024-08-07 06:24:22 +0000 Commit: Osama Abboud CommitDate: 2024-10-31 14:55:21 +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 1455d29a1f4f..a0d3cf28861e 100644 --- a/sys/dev/ena/ena.c +++ b/sys/dev/ena/ena.c @@ -3982,6 +3982,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: @@ -4032,6 +4033,8 @@ ena_detach(device_t pdev) ether_ifdetach(adapter->ifp); + ifmedia_removeall(&adapter->media); + /* Stop timer service */ ENA_LOCK_LOCK(); ENA_TIMER_DRAIN(adapter);