Skip to contentSkip to conversation

ptp: ocp: add irig and dcf NULL-check in __handle_signal functions

PATCH In review Sagi Maimon 3 participants 4 messages Apr 9, 2025 – Apr 13, 2025

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ptp: ocp: add irig and dcf NULL-check in __handle_signal functions

In __handle_signal_outputs and __handle_signal_inputs add irig and dcf NULL-check

---
 drivers/ptp/ptp_ocp.c | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)
drivers/ptp/ptp_ocp.c +8 -4
index 7945c6be1f7c..4e4a6f465b01 100644
@@ -2434,15 +2434,19 @@ ptp_ocp_dcf_in(struct ptp_ocp *bp, bool enable)
 static void
 __handle_signal_outputs(struct ptp_ocp *bp, u32 val)
 {
-	ptp_ocp_irig_out(bp, val & 0x00100010);
-	ptp_ocp_dcf_out(bp, val & 0x00200020);
+	if (bp->irig_out)
+		ptp_ocp_irig_out(bp, val & 0x00100010);
+	if (bp->dcf_out)
+		ptp_ocp_dcf_out(bp, val & 0x00200020);
 }
 
 static void
 __handle_signal_inputs(struct ptp_ocp *bp, u32 val)
 {
-	ptp_ocp_irig_in(bp, val & 0x00100010);
-	ptp_ocp_dcf_in(bp, val & 0x00200020);
+	if (bp->irig_out)
+		ptp_ocp_irig_in(bp, val & 0x00100010);
+	if (bp->dcf_out)
+		ptp_ocp_dcf_in(bp, val & 0x00200020);
 }
 
 static u32
Signature · 1 line
2.45.2
maintainer
#2 lore raw
In reply to Sagi Maimon
Quoted 2 lines · Sagi Maimon

In __handle_signal_outputs and __handle_signal_inputs add irig and dcf NULL-check

You need to expand a little the commit message. Is the NULL ptr dereference actually possible? How? or this is just defensive programming?

If there is a real NULL ptr dereference this need a suitable Fixes tag.

And you should specify the target tree in the subj prefix.

You can retain the collected ack when resubmitting.

Thanks,

Paolo

#3 lore raw

HI Paolo
Most of your notes are clear and will be fixed.
can you explain more regarding: "And you should specify the target tree in the subj prefix"
Did you mean: net, net-next, Linux-nex?

Quoted 18 lines · Paolo Abeni
Quoted 2 lines · Sagi Maimon

In __handle_signal_outputs and __handle_signal_inputs add irig and dcf NULL-check

You need to expand a little the commit message. Is the NULL ptr dereference actually possible? How? or this is just defensive programming?

If there is a real NULL ptr dereference this need a suitable Fixes tag.

And you should specify the target tree in the subj prefix.

You can retain the collected ack when resubmitting.

Thanks,

Paolo