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 B35762F2C58; Tue, 17 Jun 2025 15:46:13 +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=1750175173; cv=none; b=lfCIBSqBHejIlLNI6js1QHwJ8os2vdYQZsCA5b5EBWqJ3jfLNbq7JS87hXSNn1/JAmDoYkRYrsiGUirLmctBph3SS1lIxUjfVuzTkzezSvE9BDi5bH8HZnlQI5ypr8srHyd5mYkZ6VgacGwN45KyHdHjWBXSmkddN0m2quQRNsI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1750175173; c=relaxed/simple; bh=G4rXkfVYT+FiQUu/duuibbopjwSuYpGSPF++DPrdg94=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=dlM5W8OI/UuIGZExiNQ9WsiGTzyEeo6ylKkPYoHeqMAM7Pd4EpBn0snlx6hI24XiANRNdDngXrOHng4N8EaD70qwwj+0SbelEOKPE/gtJL/jK5wMXJs1IbzKZ10AKFfdNlpx/F8O5lPqExP7WSgSf1n1YdLdKjnhLr2EmB5yqJU= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=rOyv+PDR; 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="rOyv+PDR" Received: by smtp.kernel.org (Postfix) with ESMTPSA id CF912C4CEE7; Tue, 17 Jun 2025 15:46:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1750175173; bh=G4rXkfVYT+FiQUu/duuibbopjwSuYpGSPF++DPrdg94=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=rOyv+PDR9PYp8n3hKNOjbOfOErdBpXyukuEL9Vj3QCNqVSuSSmjQ5R/LLS5NaOKJV +JdgRFFkFLVJyGcNQtF1jzpSRQoBUh5Xq0zUxAquIp/79tQqNeMG0En8tZiUUwPWhj au385cICbd12vJJr8m8AmbuKDZ1sFu5Aq01q9R84= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Horatiu Vultur , Jakub Kicinski , Sasha Levin Subject: [PATCH 6.6 150/356] net: phy: mscc: Fix memory leak when using one step timestamping Date: Tue, 17 Jun 2025 17:24:25 +0200 Message-ID: <20250617152344.273364439@linuxfoundation.org> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250617152338.212798615@linuxfoundation.org> References: <20250617152338.212798615@linuxfoundation.org> User-Agent: quilt/0.68 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 6.6-stable review patch. If anyone has any objections, please let me know. ------------------ From: Horatiu Vultur [ Upstream commit 846992645b25ec4253167e3f931e4597eb84af56 ] 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 Link: https://patch.msgid.link/20250522115722.2827199-1-horatiu.vultur@microchip.com Signed-off-by: Jakub Kicinski Signed-off-by: Sasha Levin --- 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_ptp.c index cf728bfd83e22..af44b01f3d383 100644 --- a/drivers/net/phy/mscc/mscc_ptp.c +++ b/drivers/net/phy/mscc/mscc_ptp.c @@ -1165,18 +1165,24 @@ static void vsc85xx_txtstamp(struct mii_timestamper *mii_ts, container_of(mii_ts, struct vsc8531_private, mii_ts); if (!vsc8531->ptp->configured) - return; + goto out; - if (vsc8531->ptp->tx_type == HWTSTAMP_TX_OFF) { - kfree_skb(skb); - return; - } + if (vsc8531->ptp->tx_type == HWTSTAMP_TX_OFF) + goto out; + + if (vsc8531->ptp->tx_type == HWTSTAMP_TX_ONESTEP_SYNC) + if (ptp_msg_is_sync(skb, type)) + goto out; skb_shinfo(skb)->tx_flags |= SKBTX_IN_PROGRESS; mutex_lock(&vsc8531->ts_lock); __skb_queue_tail(&vsc8531->ptp->tx_queue, skb); mutex_unlock(&vsc8531->ts_lock); + return; + +out: + kfree_skb(skb); } static bool vsc85xx_rxtstamp(struct mii_timestamper *mii_ts, -- 2.39.5