summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeter Marheine <pmarheine@chromium.org>2020-03-19 10:25:19 +1100
committerCommit Bot <commit-bot@chromium.org>2020-03-26 02:30:48 +0000
commiteb6401aa2ccf38afadc1fc2978cbd2a6d9a7c4ce (patch)
treedcee4a4004f1b00aae4d3e673dcae928166a54f4
parente37781d3dffdee742ba9ae2d80bd600a33c28b18 (diff)
downloadchrome-ec-eb6401aa2ccf38afadc1fc2978cbd2a6d9a7c4ce.tar.gz
usbc: null-check modep when entering DP mode
If a received message has an unrecognized SVID, pd_get_amode_data will return NULL. In some cases this is normal, but any case that uses the alternate mode data must check that it's non-NULL. When connecting a weird display that seems to incorrectly advertise displayport capabilities on a port but not actually support it, without the NULL check the EC may crash or behave unpredictably when it tries to call modep->fx->status. In practice, status was also null so it crashed in a useful fashion. BUG=b:151564636 TEST=connecting a problematic device no longer crashes the EC BRANCH=None Signed-off-by: Peter Marheine <pmarheine@chromium.org> Change-Id: I6c552fb21556dd84f54e4228b5a7eeaab4a3bbca Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2108432 Reviewed-by: Andrew McRae <amcrae@chromium.org>
-rw-r--r--common/usbc/usb_pe_drp_sm.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/common/usbc/usb_pe_drp_sm.c b/common/usbc/usb_pe_drp_sm.c
index 63bd28a802..9c4acb15b9 100644
--- a/common/usbc/usb_pe_drp_sm.c
+++ b/common/usbc/usb_pe_drp_sm.c
@@ -3848,7 +3848,7 @@ static void pe_do_port_discovery_run(int port)
break;
case CMD_ENTER_MODE:
pe[port].vdm_cmd = CMD_DP_STATUS;
- if (modep->opos) {
+ if (modep && modep->opos) {
ret = modep->fx->status(port,
pe[port].vdm_data);
pe[port].vdm_data[0] |=