]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
net: gianfar: fix device leak when querying time stamp info
authorJohan Hovold <johan@kernel.org>
Fri, 25 Jul 2025 17:12:11 +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: 7349a74ea75c ("net: ethernet: gianfar_ethtool: get phc index through drvdata")
Cc: stable@vger.kernel.org # 4.18
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-4-johan@kernel.org
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
drivers/net/ethernet/freescale/gianfar_ethtool.c

index 28f53cf2a174f147624151c03268e3487e06d66e..5fd1f7327680309f8f092d041a88f16a52ab9be5 100644 (file)
@@ -1475,8 +1475,10 @@ static int gfar_get_ts_info(struct net_device *dev,
        if (ptp_node) {
                ptp_dev = of_find_device_by_node(ptp_node);
                of_node_put(ptp_node);
-               if (ptp_dev)
+               if (ptp_dev) {
                        ptp = platform_get_drvdata(ptp_dev);
+                       put_device(&ptp_dev->dev);
+               }
        }
 
        if (ptp)