]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
net: dpaa: fix device leak when querying time stamp info
authorJohan Hovold <johan@kernel.org>
Fri, 25 Jul 2025 17:12:09 +0000 (19:12 +0200)
committerJakub Kicinski <kuba@kernel.org>
Thu, 31 Jul 2025 01:02:47 +0000 (18:02 -0700)
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>
Link: https://patch.msgid.link/20250725171213.880-2-johan@kernel.org
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
drivers/net/ethernet/freescale/dpaa/dpaa_ethtool.c

index 0c588e03b15e2f38a1803615b45ae08433b16567..d09e456f14c02bcc2eae6acab4907a957416a53e 100644 (file)
@@ -371,8 +371,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;