From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wr1-f42.google.com (mail-wr1-f42.google.com [209.85.221.42]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 04979395AC7 for ; Wed, 24 Jun 2026 08:48:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.42 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1782290901; cv=none; b=MICeVQnNMqMmZayloLthAXA05aBKPFUf7gHmb55W/HiqlU0U0Qvfm/dnOxVsQ+81wul7kxLP6/45LZav6NjiHMBoewPgbAkIrP9hipkC2YSBcvTlIlN0ofNw9JeJnuXWHOQ9trA3oNHJnzw53kBfUDl3//nmvgwNQdLUk6gOSkc= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1782290901; c=relaxed/simple; bh=UQ8ZercqnEexR10BCqp8G+i78OvuTl8M+8IL2LNTl+4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Occ/2nxxF0oFBZ79KafrH48Z/zU760VT/62WxYH/KZxi7OjRdBynBJ3UJaswkK39ozoJ9bjDuz2SinLVoRSUL9Agl4oGIr1TYn2BgP2RjmfBqcnJWUDBZFIEJHiJmzQapX+/fdLHAQIXJ3v1hn8r5LCXEAZ+U1D4ufIGEMYOIJg= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=co7Du9pq; arc=none smtp.client-ip=209.85.221.42 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="co7Du9pq" Received: by mail-wr1-f42.google.com with SMTP id ffacd0b85a97d-461edb387ddso871148f8f.3 for ; Wed, 24 Jun 2026 01:48:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1782290898; x=1782895698; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=82FA35TCqJ8Eddf8LJXiGKVbEkzxEdof0NFAzA1rmpE=; b=co7Du9pqMcheFaYT/7qXObRZ5pvrSrWflCDvItHjBSzY583ppUT+anEresOV/1ZvpU EAORMU6/7AGAza2M7kYjXCMs2Jz1ulet9KvpABTxHNsrJEScnPMVnfOwf9U03diOqYNu XMZGFvW5IhN+BJ9XNeDgniqaNuOFutO2FJfgGRPQLY6QVMqJADXVyZ6HrG8san4bgD3r BgjixKPOqtAWT0hoPq2KLmp7B4i///cC65Qux6tyUFcJJHwmtFu5M9SFoFeia5LHEauv ZGEE/B+BBmwn+wNmASYVj/9pG/bFYS3AuEbRJR9mO2zpDX7A2HGxOBAseUr4koID1dOd zZ/Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1782290898; x=1782895698; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=82FA35TCqJ8Eddf8LJXiGKVbEkzxEdof0NFAzA1rmpE=; b=JZ0DbilS2KF0BNkBz/1b1Jb2fzWrAb9fXoBJUwcOywl2GWs6KQkgnvI/KnytU6xy8D b7yDpVfn4hxkNOxpj54Imeq4TDDqJcNfy0t4rkMiEX7r6jgK9LJpbEBT5XbcVL8ME2QQ V0otF8UJXh2bSkBM41EVYPCw2wvR7HIxsxLaXMaDaAcD10o8sICUpUqQ4al9hFxk1ipe BlZkLz9BaW4WTTZG52gsEGipve2CC5pMrFDZFhp+4lfSVTyKE+m9dBuuVLXYqRGd0Z9/ 5zh7Ik6UhtBVVHBmSzvGAgiLt5VVKm/a8QD0Iq8xwFs1hW1OzXwMhb753P9Gxc+BHOWn vAsQ== X-Forwarded-Encrypted: i=1; AHgh+Rob9YiFVCi/JtKulRwhgvWjp9bWt9Lk5KxoILGl/Bs6GHmJcnjtHTHGlMwfDeOlJ7qY7xCSQk5TJBMTfyA=@vger.kernel.org X-Gm-Message-State: AOJu0Yz/qpEOZbtElOVPPgL4E/8exwk5JfWFjnF+9pN7NdA++dT2DVbI FNjSNmOsUTD7A3XBCTtx144Ymt66UlWeIxf5no5VIoBFVkrVDFXP1XuI X-Gm-Gg: AfdE7ck4WHmNClORToUj0lV8cSV4fcVrkFjUXb7JzHac618pbBAUJcsW3RzrIk31+Sc AkKzTnHYheRFnfEwxthDlYBeOXzeTMQj2x8m375lk+0AnFJGEneU7W26ZkEZHNl+hokTXU9B5kH guSC7g3B8nuOecdt7TgP7qbuggFNO1xZ6ieWb3wygkzh5dA3c8ekxMjTSbY7aOGMlsk68LN0cJo 771Ph3xio8joGnAvtwJcpmxX/Dm8JTb1EyemVoBk5oqUGFj+n1OMKc5fR4wgnVLhAO5D9/Mh2bI wz8WQjqeTJ1HojjcB363EcACKbeJicjfOEpImuxgH7UgnK8hMALoH19d1jVwDdoJHjhb02a67dK s6Mm3Vy4uPnyoEoLw+QSncckeUToj84sBzedwOJAlMNj6uVDqGieWoG8gB43G0SMHc647EfC4Yh IY1og7xQjcIDkI4Oq+N4sbWBobsVX1gMOqf8vtZdcTwYzgQ7GADYlXG6GoA4CDFrY6mlt3D21v3 Bh8d4I= X-Received: by 2002:a05:6000:2587:b0:45d:41e0:467b with SMTP id ffacd0b85a97d-46c0951d92emr3798306f8f.3.1782290898438; Wed, 24 Jun 2026 01:48:18 -0700 (PDT) Received: from localhost.localdomain (ip-89-176-136-191.bb.vodafone.cz. [89.176.136.191]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-46c221d9371sm5065849f8f.21.2026.06.24.01.48.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 24 Jun 2026 01:48:17 -0700 (PDT) From: Petr Wozniak To: Russell King , Andrew Lunn , Heiner Kallweit Cc: Jakub Kicinski , "David S . Miller" , Eric Dumazet , Paolo Abeni , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, linux-phy@lists.infradead.org, Maxime Chevallier , Bjorn Mork , Aleksander Bajkowski , Marek Behun , Petr Wozniak Subject: [PATCH net v4 1/2] net: phy: sfp: free mii_bus in sfp_i2c_mdiobus_destroy Date: Wed, 24 Jun 2026 10:48:13 +0200 Message-ID: <20260624084814.20972-2-petr.wozniak@gmail.com> X-Mailer: git-send-email 2.50.1 In-Reply-To: <20260624084814.20972-1-petr.wozniak@gmail.com> References: <20260624084814.20972-1-petr.wozniak@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit sfp_i2c_mdiobus_create() allocates the I2C MDIO bus with mdio_i2c_alloc(), a plain (non-devm) allocation, and registers it. sfp_i2c_mdiobus_destroy() only unregisters the bus and clears sfp->i2c_mii without calling mdiobus_free(). As the only reference to the bus is then cleared, the struct mii_bus is leaked. This is hit whenever a copper/RollBall SFP module that instantiated an MDIO bus is removed: sfp_sm_main() takes the global teardown path and calls sfp_i2c_mdiobus_destroy(). sfp_cleanup(), on driver unbind, frees sfp->i2c_mii directly, which is why the leak only triggered on module hot-removal and not on unbind. Free the bus in sfp_i2c_mdiobus_destroy() to match the allocation done in sfp_i2c_mdiobus_create(). Fixes: e85b1347ace6 ("net: sfp: create/destroy I2C mdiobus before PHY probe/after PHY release") Signed-off-by: Petr Wozniak Reviewed-by: Maxime Chevallier --- drivers/net/phy/sfp.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/net/phy/sfp.c b/drivers/net/phy/sfp.c index 03bfd8640db9..c4d274ab651e 100644 --- a/drivers/net/phy/sfp.c +++ b/drivers/net/phy/sfp.c @@ -963,6 +963,7 @@ static int sfp_i2c_mdiobus_create(struct sfp *sfp) static void sfp_i2c_mdiobus_destroy(struct sfp *sfp) { mdiobus_unregister(sfp->i2c_mii); + mdiobus_free(sfp->i2c_mii); sfp->i2c_mii = NULL; } -- 2.51.0