Merge "usb: dwc3-msm-core: Prevent NULL pointer deref from pwr_event_handler"

This commit is contained in:
qctecmdr 2023-09-26 11:31:11 -07:00 committed by Gerrit - the friendly Code Review server
commit ef7d5d5c5c

View File

@ -4603,6 +4603,9 @@ static void dwc3_pwr_event_handler(struct dwc3_msm *mdwc)
if (mdwc->dwc3)
dwc = platform_get_drvdata(mdwc->dwc3);
if (!mdwc->ip)
mdwc->ip = DWC3_GSNPS_ID(dwc3_msm_read_reg(mdwc->base, DWC3_GSNPSID));
irq_stat = dwc3_msm_read_reg(mdwc->base, PWR_EVNT_IRQ_STAT_REG);
dev_dbg(mdwc->dev, "%s irq_stat=%X\n", __func__, irq_stat);
@ -4612,7 +4615,7 @@ static void dwc3_pwr_event_handler(struct dwc3_msm *mdwc)
u32 ls;
/* Can't tell if entered or exit P3, so check LINKSTATE */
if (!DWC3_IP_IS(DWC3))
if (mdwc->ip == DWC31_IP)
ls = dwc3_msm_read_reg_field(mdwc->base,
DWC31_LINK_GDBGLTSSM,
DWC3_GDBGLTSSM_LINKSTATE_MASK);