public inbox for netdev@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] net/mlx5: Fix potential NULL dereference in PTP event handling
@ 2026-03-31 15:31 Prathamesh Deshpande
  2026-04-02  0:30 ` [PATCH v2] net/mlx5: Fix OOB access and stack information leak " Prathamesh Deshpande
  0 siblings, 1 reply; 2+ messages in thread
From: Prathamesh Deshpande @ 2026-03-31 15:31 UTC (permalink / raw)
  To: Saeed Mahameed, Leon Romanovsky, Tariq Toukan
  Cc: Mark Bloch, Richard Cochran, netdev, linux-rdma, linux-kernel,
	Prathamesh Deshpande

In mlx5_ptp_pps_event(), a TODO comment correctly identified that
clock->ptp can be NULL if ptp_clock_register() fails. However, the
code proceeded to call ptp_clock_event() with that NULL pointer,
leading to a potential kernel panic.

Fix this by adding a NULL check for clock->ptp before calling
ptp_clock_event(), ensuring the driver handles failed registration
gracefully.

Fixes: 7c39afb394c7 ("net/mlx5: PTP code migration to driver core section")

Signed-off-by: Prathamesh Deshpande <prathameshdeshpande7@gmail.com>
---
 drivers/net/ethernet/mellanox/mlx5/core/lib/clock.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/net/ethernet/mellanox/mlx5/core/lib/clock.c b/drivers/net/ethernet/mellanox/mlx5/core/lib/clock.c
index bd4e042077af..9e9f844935b4 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/lib/clock.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/lib/clock.c
@@ -1185,8 +1185,8 @@ static int mlx5_pps_event(struct notifier_block *nb,
 		} else {
 			ptp_event.type = PTP_CLOCK_EXTTS;
 		}
-		/* TODOL clock->ptp can be NULL if ptp_clock_register fails */
-		ptp_clock_event(clock->ptp, &ptp_event);
+		if (clock->ptp)
+			ptp_clock_event(clock->ptp, &ptp_event);
 		break;
 	case PTP_PF_PEROUT:
 		if (clock->shared) {
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-04-02  0:31 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-03-31 15:31 [PATCH] net/mlx5: Fix potential NULL dereference in PTP event handling Prathamesh Deshpande
2026-04-02  0:30 ` [PATCH v2] net/mlx5: Fix OOB access and stack information leak " Prathamesh Deshpande

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox