From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 096722E859; Fri, 6 Dec 2024 15:10:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733497806; cv=none; b=DLtU9mot2Sqh4w+2ONBb9HFUB+dmxB+2DxvZLRMXHBea3+mdi8oMHr66qNVzTyAVuujJB1cgQX5u14LMuDywl4aQlnwaq7M+EdGlrbHhBrG/+okPAtAVqpfeqcZPBB7XZ4ULpjpi+jcewdSRJHhH90ltQqZpuv4Vl9ZnHAdk7U4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733497806; c=relaxed/simple; bh=CalW6u6LAFRqxeNRgMcWJU/gQ7+rGaVos+cp3t6ulz4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Alm9N28tOXl01HIWrPz/Lvir+RYrSGWGqCrQkESWvfaTedOtauTDriWEPz5UY8rB0U4mTDiLn/4jYtKgUueuTTAcyZWINvrsdmLiBF9Xif8K3z0cp0T31I3cwSn5WXvHZFyyl4hu4845jhF+YRZIQZGRf3quWvNKqbpMWjd7z/Q= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=LhWji0to; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="LhWji0to" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 78541C4CED1; Fri, 6 Dec 2024 15:10:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1733497805; bh=CalW6u6LAFRqxeNRgMcWJU/gQ7+rGaVos+cp3t6ulz4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=LhWji0toNAP28FjKAMINDUcHUHhqbMaPvumidb0w1sFF65ft/Axb8AdwSQtHn34dh XCW/Z/zDwa4a9wJD3+Q97ZcrEsH6DViVfnt9x8QZ6KKzCHd8kzbUAOhMhUreMrM5Fr z2s0NAGQYxP+3SfaPKDBGgbeFImpexjiiju5tAq4= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Raghuram Chary J , Oleksij Rempel , Jakub Kicinski , Sasha Levin Subject: [PATCH 6.6 399/676] net: usb: lan78xx: Fix memory leak on device unplug by freeing PHY device Date: Fri, 6 Dec 2024 15:33:38 +0100 Message-ID: <20241206143708.936508209@linuxfoundation.org> X-Mailer: git-send-email 2.47.1 In-Reply-To: <20241206143653.344873888@linuxfoundation.org> References: <20241206143653.344873888@linuxfoundation.org> User-Agent: quilt/0.67 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: stable@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.6-stable review patch. If anyone has any objections, please let me know. ------------------ From: Oleksij Rempel [ Upstream commit ae7370e61c5d8f5bcefc2d4fca724bd4e9bbf789 ] Add calls to `phy_device_free` after `fixed_phy_unregister` to fix a memory leak that occurs when the device is unplugged. This ensures proper cleanup of pseudo fixed-link PHYs. Fixes: 89b36fb5e532 ("lan78xx: Lan7801 Support for Fixed PHY") Cc: Raghuram Chary J Signed-off-by: Oleksij Rempel Link: https://patch.msgid.link/20241116130558.1352230-2-o.rempel@pengutronix.de Signed-off-by: Jakub Kicinski Signed-off-by: Sasha Levin --- drivers/net/usb/lan78xx.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/drivers/net/usb/lan78xx.c b/drivers/net/usb/lan78xx.c index 2ae33ecb67494..2e02f17beb09d 100644 --- a/drivers/net/usb/lan78xx.c +++ b/drivers/net/usb/lan78xx.c @@ -2387,6 +2387,7 @@ static int lan78xx_phy_init(struct lan78xx_net *dev) if (dev->chipid == ID_REV_CHIP_ID_7801_) { if (phy_is_pseudo_fixed_link(phydev)) { fixed_phy_unregister(phydev); + phy_device_free(phydev); } else { phy_unregister_fixup_for_uid(PHY_KSZ9031RNX, 0xfffffff0); @@ -4246,8 +4247,10 @@ static void lan78xx_disconnect(struct usb_interface *intf) phy_disconnect(net->phydev); - if (phy_is_pseudo_fixed_link(phydev)) + if (phy_is_pseudo_fixed_link(phydev)) { fixed_phy_unregister(phydev); + phy_device_free(phydev); + } usb_scuttle_anchored_urbs(&dev->deferred); -- 2.43.0