[PATCH 1/5] net: dpaa: fix device leak when querying time stamp info

Johan Hovold posted 5 patches 2 months, 1 week ago
[PATCH 1/5] net: dpaa: fix device leak when querying time stamp info
Posted by Johan Hovold 2 months, 1 week ago
Make sure to drop the reference to the ptp device taken by
of_find_device_by_node() when querying the time stamping capabilities.

Note that holding a reference to the ptp device does not prevent its
driver data from going away.

Fixes: 17ae0b0ee9db ("dpaa_eth: add the get_ts_info interface for ethtool")
Cc: stable@vger.kernel.org	# 4.19
Cc: Yangbo Lu <yangbo.lu@nxp.com>
Signed-off-by: Johan Hovold <johan@kernel.org>
---
 drivers/net/ethernet/freescale/dpaa/dpaa_ethtool.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/freescale/dpaa/dpaa_ethtool.c b/drivers/net/ethernet/freescale/dpaa/dpaa_ethtool.c
index 9986f6e1f587..7fc01baef280 100644
--- a/drivers/net/ethernet/freescale/dpaa/dpaa_ethtool.c
+++ b/drivers/net/ethernet/freescale/dpaa/dpaa_ethtool.c
@@ -401,8 +401,10 @@ static int dpaa_get_ts_info(struct net_device *net_dev,
 		of_node_put(ptp_node);
 	}
 
-	if (ptp_dev)
+	if (ptp_dev) {
 		ptp = platform_get_drvdata(ptp_dev);
+		put_device(&ptp_dev->dev);
+	}
 
 	if (ptp)
 		info->phc_index = ptp->phc_index;
-- 
2.49.1
Re: [PATCH 1/5] net: dpaa: fix device leak when querying time stamp info
Posted by Simon Horman 2 months, 1 week ago
On Fri, Jul 25, 2025 at 07:12:09PM +0200, Johan Hovold wrote:
> Make sure to drop the reference to the ptp device taken by
> of_find_device_by_node() when querying the time stamping capabilities.
> 
> Note that holding a reference to the ptp device does not prevent its
> driver data from going away.
> 
> Fixes: 17ae0b0ee9db ("dpaa_eth: add the get_ts_info interface for ethtool")
> Cc: stable@vger.kernel.org	# 4.19
> Cc: Yangbo Lu <yangbo.lu@nxp.com>
> Signed-off-by: Johan Hovold <johan@kernel.org>

Reviewed-by: Simon Horman <horms@kernel.org>