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 6C0001F8923; Tue, 3 Dec 2024 16:05:19 +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=1733241919; cv=none; b=lRQHyGM4nsTQwfUsqEPjqmUaP5qf87fV00Vmfk6pMXiVTGM8QzC8N2EnyTWlcimGNya6icPPlUS8AYpiVGPHGA6Gf1O/DW9F3a750KJ/B4oh6TXHdxTvHHeQ4dopKmScOC7TkGIMQtSH/kAM5hHen9uhUwlfFpk/3NVU1Ty/8Ns= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733241919; c=relaxed/simple; bh=CDDezxI2BV5nd4xaFPYlc5jgz5abV9E1UNLrTjrGL/0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Z3+9HWbubyhbprzsQAvVPPO2rjP6ZpQxUJOl0Jrz9SAgfkRouHSI3d1qNdAofep8grJQaEeDvI12JLwpC4c3TbtMsGnK2iWT+bYb4Jq6Nl4o6CDye9YPOGD3xPISpLSJEXViYwnt5fptKtJlLV/UxZ7OkEEoWpSYSS20xPkwx6I= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=c5K2PeCc; 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="c5K2PeCc" Received: by smtp.kernel.org (Postfix) with ESMTPSA id CF7A5C4CED8; Tue, 3 Dec 2024 16:05:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1733241919; bh=CDDezxI2BV5nd4xaFPYlc5jgz5abV9E1UNLrTjrGL/0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=c5K2PeCc+xrOY0kOg1erPqUQu1z7jCUs/PlDJ/8DPQ9GSp85HLS31LVZ3osmdCGgh 2Bnuw3iJywfwPN8jYW5SH+W6Tgs4xqsLcuocbAEIkzdGbVGRNODmXEPuUyXVJ54CBm Bgy8SF0rQDN69sBy/o3VZsF3UzJRRLqa4wJxfM6I= 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.12 555/826] net: usb: lan78xx: Fix memory leak on device unplug by freeing PHY device Date: Tue, 3 Dec 2024 15:44:42 +0100 Message-ID: <20241203144805.396838412@linuxfoundation.org> X-Mailer: git-send-email 2.47.1 In-Reply-To: <20241203144743.428732212@linuxfoundation.org> References: <20241203144743.428732212@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.12-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 094a47b8b97eb..9f191b6ce8215 100644 --- a/drivers/net/usb/lan78xx.c +++ b/drivers/net/usb/lan78xx.c @@ -2380,6 +2380,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