Skip to content

Commit 319a782

Browse files
Pavan ChebbiPaolo Abeni
authored andcommitted
bnxt_en: Prevent kernel panic when receiving unexpected PHC_UPDATE event
The firmware can send PHC_RTC_UPDATE async event on a PF that may not have PTP registered. In such a case, there will be a null pointer deference for bp->ptp_cfg when we try to handle the event. Fix it by not registering for this event with the firmware if !bp->ptp_cfg. Also, check that bp->ptp_cfg is valid before proceeding when we receive the event. Fixes: 8bcf6f0 ("bnxt_en: Handle async event when the PHC is updated in RTC mode") Signed-off-by: Pavan Chebbi <[email protected]> Signed-off-by: Michael Chan <[email protected]> Signed-off-by: Paolo Abeni <[email protected]>
1 parent 83474a9 commit 319a782

File tree

2 files changed

+7
-0
lines changed

2 files changed

+7
-0
lines changed

drivers/net/ethernet/broadcom/bnxt/bnxt.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2365,6 +2365,9 @@ static int bnxt_async_event_process(struct bnxt *bp,
23652365
struct bnxt_ptp_cfg *ptp = bp->ptp_cfg;
23662366
u64 ns;
23672367

2368+
if (!ptp)
2369+
goto async_event_process_exit;
2370+
23682371
spin_lock_bh(&ptp->ptp_lock);
23692372
bnxt_ptp_update_current_time(bp);
23702373
ns = (((u64)BNXT_EVENT_PHC_RTC_UPDATE(data1) <<
@@ -4763,6 +4766,9 @@ int bnxt_hwrm_func_drv_rgtr(struct bnxt *bp, unsigned long *bmap, int bmap_size,
47634766
if (event_id == ASYNC_EVENT_CMPL_EVENT_ID_ERROR_RECOVERY &&
47644767
!(bp->fw_cap & BNXT_FW_CAP_ERROR_RECOVERY))
47654768
continue;
4769+
if (event_id == ASYNC_EVENT_CMPL_EVENT_ID_PHC_UPDATE &&
4770+
!bp->ptp_cfg)
4771+
continue;
47664772
__set_bit(bnxt_async_events_arr[i], async_events_bmap);
47674773
}
47684774
if (bmap && bmap_size) {

drivers/net/ethernet/broadcom/bnxt/bnxt_ptp.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -952,6 +952,7 @@ int bnxt_ptp_init(struct bnxt *bp, bool phc_cfg)
952952
bnxt_ptp_timecounter_init(bp, true);
953953
bnxt_ptp_adjfine_rtc(bp, 0);
954954
}
955+
bnxt_hwrm_func_drv_rgtr(bp, NULL, 0, true);
955956

956957
ptp->ptp_info = bnxt_ptp_caps;
957958
if ((bp->fw_cap & BNXT_FW_CAP_PTP_PPS)) {

0 commit comments

Comments
 (0)