summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBoris Mittelberg <bmbm@google.com>2022-11-09 15:54:10 -0800
committerChromeos LUCI <chromeos-scoped@luci-project-accounts.iam.gserviceaccount.com>2022-11-24 01:00:24 +0000
commit667d7d7129a1d3d7b33046755030ec5fdce1ac32 (patch)
tree81187e9e4d30ac73af8e59e8dc185de18ed3ecb9
parentd6a129f6bff2021ad787f7bf298252b2407edbb7 (diff)
downloadchrome-ec-667d7d7129a1d3d7b33046755030ec5fdce1ac32.tar.gz
dp-alt-mode: add safety check
Prevent possible NULL dereference BUG=b:64477774 BRANCH=none TEST=make buildall LOW_COVERAGE_REASON=No unit test infrastructure for this module Signed-off-by: Boris Mittelberg <bmbm@google.com> Change-Id: I1e42037d09ae41b8fc9acc611dd9fe2811e7f620 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4018490 Code-Coverage: Zoss <zoss-cl-coverage@prod.google.com> Reviewed-by: Diana Z <dzigterman@chromium.org>
-rw-r--r--common/usbc/dp_alt_mode.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/common/usbc/dp_alt_mode.c b/common/usbc/dp_alt_mode.c
index f53d212b91..1fb99fd797 100644
--- a/common/usbc/dp_alt_mode.c
+++ b/common/usbc/dp_alt_mode.c
@@ -306,13 +306,13 @@ enum dpm_msg_setup_status dp_setup_next_vdm(int port, int *vdo_count,
* this doesn't set up the VDM, it clears state.
* TODO(b/159856063): Clean up the API to the fx functions.
*/
- if (!(modep && modep->opos))
- return MSG_SETUP_ERROR;
-
usb_mux_set_safe_mode_exit(port);
dp_state[port] = DP_PREPARE_EXIT;
return MSG_SETUP_MUX_WAIT;
case DP_PREPARE_EXIT:
+ if (!(modep && modep->opos))
+ return MSG_SETUP_ERROR;
+
/* DPM should call setup only after safe state is set */
vdm[0] = VDO(USB_SID_DISPLAYPORT, 1, /* structured */
CMD_EXIT_MODE);