From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (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 685D44CA784; Wed, 30 Sep 2026 16:53:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1790787181; cv=none; b=Veh2aIFQnyphRXUYOWfWyrYyAsRGrClCxUZT//WwTWyhMl0soOqJC+EiNKk50s8urea9KY8HhcoQH+0oGHt7GIQyQ9fiiLii0BxmcTKipSZ2rqofNPUVBNMVQE384xXyEjNUPdxlLuFRzcvEbdykH5a64X5gDityRI4T35VsLkg= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1790787181; c=relaxed/simple; bh=7t9YKZJZTGZ+9Fjd70WHPQNDu58aLiIlyBoArnoPVxU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=a74E5j50sj9L5xPBg/a4N1WqpcmEey5nAErjcNEMrdbb+VOImqbUcz5Vdd7BagQCQX08GxMP5u83AqpM4Ad9eK/7qlFhvRwVSO3RifwOhqyPcC5yG/frPri1XP2eX+N/56RxsDb5Y1YCY650tZgKCJhcvno1co9NrJmtA9DDPHY= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=kwLL/4u1; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="kwLL/4u1" Received: by smtp.kernel.org (Postfix) with ESMTPSA id B88681F000FF; Wed, 30 Sep 2026 16:52:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1790787180; bh=kV2ZjmndaItoNwdgGpXHDexMWZgWy7Fuvpq5ORx/TNg=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=kwLL/4u17cmntECLcWZSCbqMN8qjUxHI00plFifBW+mTM3NVuSHaLWLa/u+hFE8aI aSjjI0Lp9zsxdXcnk6ZuMLW0c9gBi4E2kUYIdEzPVI6rxAh+Kbl81RJpT0XuJWaJNJ X1Ewi3ta1TpmZuY1aAxwHVk5fzYPPnfumSP+zDr4= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Ijae Kim , Myeonghun Pak , Paolo Abeni , Sasha Levin Subject: [PATCH 7.2 139/457] tg3: clean up PHYLIB resources on probe failure Date: Wed, 30 Sep 2026 17:24:04 +0200 Message-ID: <20260930152349.049654935@linuxfoundation.org> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260930152346.024115587@linuxfoundation.org> References: <20260930152346.024115587@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 7.2-stable review patch. If anyone has any objections, please let me know. ------------------ From: Myeonghun Pak [ Upstream commit a92e1a412c53dc0d9ad639e7abf8b3fc70a5b6ad ] tg3_get_invariants() can register an MDIO bus and connect a PHY for USE_PHYLIB devices. If tg3_init_one() later fails, its common error path releases the mappings and netdev without undoing those PHYLIB resources. Disconnect the PHY and unregister the MDIO bus before the remaining teardown. Guard PHY cleanup with USE_PHYLIB to match tg3_phy_init(), and call tg3_mdio_fini() unconditionally to match tg3_mdio_init(). The existing IS_CONNECTED and MDIOBUS_INITED flags make both helpers safe when initialization only completed partially. This issue was identified during our ongoing static-analysis research while reviewing kernel code. Fixes: 158d7abdae85 ("tg3: Add mdio bus registration") Assisted-by: OpenAI:GPT-5.6 Co-developed-by: Ijae Kim Signed-off-by: Ijae Kim Signed-off-by: Myeonghun Pak Link: https://patch.msgid.link/20260917183336.36239-1-mhun512@gmail.com Signed-off-by: Paolo Abeni Signed-off-by: Sasha Levin --- drivers/net/ethernet/broadcom/tg3.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drivers/net/ethernet/broadcom/tg3.c b/drivers/net/ethernet/broadcom/tg3.c index 73a4b569b03e3..caa7a6caa6e2f 100644 --- a/drivers/net/ethernet/broadcom/tg3.c +++ b/drivers/net/ethernet/broadcom/tg3.c @@ -18047,6 +18047,10 @@ static int tg3_init_one(struct pci_dev *pdev, return 0; err_out_apeunmap: + if (tg3_flag(tp, USE_PHYLIB)) + tg3_phy_fini(tp); + tg3_mdio_fini(tp); + if (tp->aperegs) { iounmap(tp->aperegs); tp->aperegs = NULL; -- 2.53.0