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 2C25E2EF66C; Fri, 25 Jul 2025 17:14:15 +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=1753463655; cv=none; b=mFAe55OI+2uPwkYKNctL8def0hM60OIbs+ciPGy58ewj/ixaVA01ljB2mrsfoTukHs2AoA4gwxP3b9nrJgSUgsKEqeaSAT7IftgX2A4yDNJVVDubGKxDOPNgyEhjOus4eXHylSVp9ry2OMPi0X/QKA0kHVdRGkdcK89cXAA/rTk= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1753463655; c=relaxed/simple; bh=gWZO1ES2r3jh5Yq67JXLsbmiESc165KttdqT3NHuvcw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=MshE3zUfl5wC318sBIjr0da3vmTw3oUh3TxudyY8nRdyOnT6cI9sI1e+ZIDBBRiu0NLLexi56Dg0iq/e9w+/VgZMkkNOGCIDm+BRvJUVBn13DOx/Ow+w8B/S04CWJbRTJuJBApg/yrzH9/M+7VJCjQRSZU2yZZDmuhOmUoQlFFU= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=Hl1wDLS4; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="Hl1wDLS4" Received: by smtp.kernel.org (Postfix) with ESMTPSA id CC3B4C4CEFA; Fri, 25 Jul 2025 17:14:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1753463654; bh=gWZO1ES2r3jh5Yq67JXLsbmiESc165KttdqT3NHuvcw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Hl1wDLS4RHtasJPd9cADa4JxDlrhcvWQECdErTzeMhnBp1xwsq+q13wvPJxhoc2kz FN2URXemjnzNNmSAaGch5rdbzvWVbTuSzwqjge66PPZV4BmN8eYzzfS/+jrN7W1fk/ 3K3gME7exeOcgJ9z1cQ259SYUbt+Eu0wV4i1675vo9wUCg9LjgykI0v64PZ9CbY+FQ uGYhJbAQIksIkkGOArt7BWRWLReAr7W38T8C20KMcN/scav9OXVe7Rw18ItnxykKPV Aq/usys1+lcgIM1sWxyLazT0OFKkxqrpIS+yVQRQ8zK9t5kW+BVDWQrfEcx9PN793a 2grxKjo+vLG6w== Received: from johan by xi.lan with local (Exim 4.98.2) (envelope-from ) id 1ufLzn-000000000Gn-2s8N; Fri, 25 Jul 2025 19:14:11 +0200 From: Johan Hovold To: Andrew Lunn , "David S . Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni Cc: Madalin Bucur , Claudiu Manoil , Vladimir Oltean , Wei Fang , Clark Wang , Felix Fietkau , Sean Wang , Lorenzo Bianconi , Matthias Brugger , AngeloGioacchino Del Regno , MD Danish Anwar , Roger Quadros , Richard Cochran , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Johan Hovold , stable@vger.kernel.org, Yangbo Lu Subject: [PATCH 3/5] net: gianfar: fix device leak when querying time stamp info Date: Fri, 25 Jul 2025 19:12:11 +0200 Message-ID: <20250725171213.880-4-johan@kernel.org> X-Mailer: git-send-email 2.49.1 In-Reply-To: <20250725171213.880-1-johan@kernel.org> References: <20250725171213.880-1-johan@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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 Signed-off-by: Johan Hovold --- drivers/net/ethernet/freescale/gianfar_ethtool.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/net/ethernet/freescale/gianfar_ethtool.c b/drivers/net/ethernet/freescale/gianfar_ethtool.c index 781d92e703cb..c9992ed4e301 100644 --- a/drivers/net/ethernet/freescale/gianfar_ethtool.c +++ b/drivers/net/ethernet/freescale/gianfar_ethtool.c @@ -1466,8 +1466,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) -- 2.49.1