bnxt_en: Prevent kernel panic when receiving unexpected PHC_UPDATE event
authorPavan Chebbi <pavan.chebbi@broadcom.com>
Wed, 7 Jun 2023 07:54:08 +0000 (00:54 -0700)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 14 Jun 2023 09:15:23 +0000 (11:15 +0200)
commitabc7062313729743132a4dc60248d701a4ddbda2
treeab190addb40e59e2b369b3ae9e25080d10dbc657
parent5ce24936d560f226899e3dbf01987668b39fac09
bnxt_en: Prevent kernel panic when receiving unexpected PHC_UPDATE event

[ Upstream commit 319a7827df9784048abe072afe6b4fb4501d8de4 ]

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: 8bcf6f04d4a5 ("bnxt_en: Handle async event when the PHC is updated in RTC mode")
Signed-off-by: Pavan Chebbi <pavan.chebbi@broadcom.com>
Signed-off-by: Michael Chan <michael.chan@broadcom.com>
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/net/ethernet/broadcom/bnxt/bnxt.c
drivers/net/ethernet/broadcom/bnxt/bnxt_ptp.c