From nobody Sun Dec 14 12:37:54 2025 Received: from esa.microchip.iphmx.com (esa.microchip.iphmx.com [68.232.153.233]) (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 85BDD28934B; Thu, 22 May 2025 11:59:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=68.232.153.233 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1747915192; cv=none; b=IZqY/00fTFHaWwc++6xYoqTw25ZHFqoCmktJ9b2vtHY4hufwEZ+G1VF1zz0m7G8nSRXkXLKMw/of8bl1H8whuzDtF5fkg7rbgzWXuABz7bCZwMumy01gNmf5yqVC+2M65PIjc1HqWBA7WCiFq9nKyC3TKbmLmfJDTTMaKg7sB3w= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1747915192; c=relaxed/simple; bh=PF9dmA4Hm1iB100iBDu8fLWsebQWAajt/CAuvNHw/b4=; h=From:To:CC:Subject:Date:Message-ID:MIME-Version:Content-Type; b=cNal2sVzU3030HdXOPdbUDfZ1kwgpmKAoOjPYsDY7N5XwHuUElyGhFlB4xHnOcgBaozdvPJud2VN+E4i8Ifz2TPEhP34dz2B7KuMGqowTS6oq5aj/sc+vv+WvvNnj1rgiQyGmh/39b6h92JC7RPBmKS7bj+F0Jp7xhDFAOqlHNU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=microchip.com; spf=pass smtp.mailfrom=microchip.com; dkim=pass (2048-bit key) header.d=microchip.com header.i=@microchip.com header.b=oXLSj4+A; arc=none smtp.client-ip=68.232.153.233 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=microchip.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=microchip.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=microchip.com header.i=@microchip.com header.b="oXLSj4+A" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=microchip.com; i=@microchip.com; q=dns/txt; s=mchp; t=1747915190; x=1779451190; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=PF9dmA4Hm1iB100iBDu8fLWsebQWAajt/CAuvNHw/b4=; b=oXLSj4+AM6V7Hx6H4Vd/MTGTw/ap19zOVrMqRhzPYOx5v+uR8jerXbDI fmpTHj2WMD0/WTMOOtJnX1+0vbU+7biawwQXfJAUne69zEcqd2fH9mlPg CyIZIyoUYE8FRZ9mWO+7dfIIwGBqW+D2q0FP1E5shcRLJqpWT+usr8Lb5 EgbKlZAis/GtMXFzGfsitmqwZFX6FZovnvH3wwm6x6LjJ3xFp0XVfUPF+ 4XvBMP82KXHI0gyzHBG+2t/LAmm7oFcn0sraji9/ALozsYlrTncx7Dh96 rc8X1XQhrP5r1PxYiGUWnGwVs94/TWM1vsvc/Qxaf1dV6Qfj063R8sE3n Q==; X-CSE-ConnectionGUID: Qq+9gTYBQQW18d+HaTQ8Ow== X-CSE-MsgGUID: 2s/v/hcwTQuInFP4o9FnRA== X-IronPort-AV: E=Sophos;i="6.15,306,1739862000"; d="scan'208";a="46766031" X-Amp-Result: SKIPPED(no attachment in message) Received: from unknown (HELO email.microchip.com) ([170.129.1.10]) by esa1.microchip.iphmx.com with ESMTP/TLS/ECDHE-RSA-AES128-GCM-SHA256; 22 May 2025 04:59:49 -0700 Received: from chn-vm-ex03.mchp-main.com (10.10.85.151) by chn-vm-ex03.mchp-main.com (10.10.85.151) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.44; Thu, 22 May 2025 04:59:09 -0700 Received: from DEN-DL-M31836.microchip.com (10.10.85.11) by chn-vm-ex03.mchp-main.com (10.10.85.151) with Microsoft SMTP Server id 15.1.2507.44 via Frontend Transport; Thu, 22 May 2025 04:59:06 -0700 From: Horatiu Vultur To: , , , , , , , , , , , , , CC: , , Horatiu Vultur Subject: [PATCH net v2] net: phy: mscc: Fix memory leak when using one step timestamping Date: Thu, 22 May 2025 13:57:22 +0200 Message-ID: <20250522115722.2827199-1-horatiu.vultur@microchip.com> X-Mailer: git-send-email 2.34.1 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Fix memory leak when running one-step timestamping. When running one-step sync timestamping, the HW is configured to insert the TX time into the frame, so there is no reason to keep the skb anymore. As in this case the HW will never generate an interrupt to say that the frame was timestamped, then the frame will never released. Fix this by freeing the frame in case of one-step timestamping. Fixes: 7d272e63e0979d ("net: phy: mscc: timestamping and PHC support") Signed-off-by: Horatiu Vultur --- v1->v2: Free the skb also when ptp is not configured --- drivers/net/phy/mscc/mscc_ptp.c | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/drivers/net/phy/mscc/mscc_ptp.c b/drivers/net/phy/mscc/mscc_pt= p.c index ed8fb14a7f215..6f96f2679f0bf 100644 --- a/drivers/net/phy/mscc/mscc_ptp.c +++ b/drivers/net/phy/mscc/mscc_ptp.c @@ -1166,18 +1166,24 @@ static void vsc85xx_txtstamp(struct mii_timestamper= *mii_ts, container_of(mii_ts, struct vsc8531_private, mii_ts); =20 if (!vsc8531->ptp->configured) - return; + goto out; =20 - if (vsc8531->ptp->tx_type =3D=3D HWTSTAMP_TX_OFF) { - kfree_skb(skb); - return; - } + if (vsc8531->ptp->tx_type =3D=3D HWTSTAMP_TX_OFF) + goto out; + + if (vsc8531->ptp->tx_type =3D=3D HWTSTAMP_TX_ONESTEP_SYNC) + if (ptp_msg_is_sync(skb, type)) + goto out; =20 skb_shinfo(skb)->tx_flags |=3D SKBTX_IN_PROGRESS; =20 mutex_lock(&vsc8531->ts_lock); __skb_queue_tail(&vsc8531->ptp->tx_queue, skb); mutex_unlock(&vsc8531->ts_lock); + return; + +out: + kfree_skb(skb); } =20 static bool vsc85xx_rxtstamp(struct mii_timestamper *mii_ts, --=20 2.34.1