netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v1] ptp: ocp: fix NULL deref in _signal_summary_show
@ 2025-04-14  8:54 Sagi Maimon
  2025-04-14  9:37 ` Vadim Fedorenko
  0 siblings, 1 reply; 14+ messages in thread
From: Sagi Maimon @ 2025-04-14  8:54 UTC (permalink / raw)
  To: jonathan.lemon, vadim.fedorenko, richardcochran, andrew+netdev,
	davem, edumazet, kuba, pabeni
  Cc: linux-kernel, netdev, Sagi Maimon

Sysfs signal show operations can invoke _signal_summary_show before
signal_out array elements are initialized, causing a NULL pointer
dereference. Add NULL checks for signal_out elements to prevent kernel
crashes.

Fixes: b325af3cfab9 ("ptp: ocp: Add signal generators and update sysfs nodes")
Signed-off-by: Sagi Maimon <maimon.sagi@gmail.com>
---
 drivers/ptp/ptp_ocp.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/ptp/ptp_ocp.c b/drivers/ptp/ptp_ocp.c
index 7945c6be1f7c..4c7893539cec 100644
--- a/drivers/ptp/ptp_ocp.c
+++ b/drivers/ptp/ptp_ocp.c
@@ -3963,6 +3963,9 @@ _signal_summary_show(struct seq_file *s, struct ptp_ocp *bp, int nr)
 	bool on;
 	u32 val;
 
+	if (!bp->signal_out[nr])
+		return;
+
 	on = signal->running;
 	sprintf(label, "GEN%d", nr + 1);
 	seq_printf(s, "%7s: %s, period:%llu duty:%d%% phase:%llu pol:%d",
-- 
2.47.0


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

end of thread, other threads:[~2025-04-30  9:52 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-04-14  8:54 [PATCH v1] ptp: ocp: fix NULL deref in _signal_summary_show Sagi Maimon
2025-04-14  9:37 ` Vadim Fedorenko
2025-04-14 10:56   ` Sagi Maimon
2025-04-14 11:09     ` Vadim Fedorenko
2025-04-14 11:38       ` Sagi Maimon
2025-04-14 13:01         ` Vadim Fedorenko
2025-04-14 13:43           ` Sagi Maimon
2025-04-14 13:54             ` Vadim Fedorenko
2025-04-16  6:33               ` Sagi Maimon
2025-04-16 10:35                 ` Vadim Fedorenko
2025-04-16 13:59                   ` Sagi Maimon
2025-04-16 14:45                     ` Vadim Fedorenko
2025-04-29  8:42                       ` Sagi Maimon
2025-04-30  9:52                         ` Vadim Fedorenko

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).