Skip to content

Commit 8f355e5

Browse files
ecree-solarflaredavem330
authored andcommitted
sfc: check for NULL efx->ptp_data in efx_ptp_event
If we receive a PTP event from the NIC when we haven't set up PTP state in the driver, we attempt to read through a NULL pointer efx->ptp_data, triggering a panic. Signed-off-by: Edward Cree <ecree@solarflare.com> Acked-by: Shradha Shah <sshah@solarflare.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent 9a9bfd0 commit 8f355e5

File tree

1 file changed

+7
-0
lines changed
  • drivers/net/ethernet/sfc

1 file changed

+7
-0
lines changed

drivers/net/ethernet/sfc/ptp.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1668,6 +1668,13 @@ void efx_ptp_event(struct efx_nic *efx, efx_qword_t *ev)
16681668
struct efx_ptp_data *ptp = efx->ptp_data;
16691669
int code = EFX_QWORD_FIELD(*ev, MCDI_EVENT_CODE);
16701670

1671+
if (!ptp) {
1672+
if (net_ratelimit())
1673+
netif_warn(efx, drv, efx->net_dev,
1674+
"Received PTP event but PTP not set up\n");
1675+
return;
1676+
}
1677+
16711678
if (!ptp->enabled)
16721679
return;
16731680

0 commit comments

Comments
 (0)