diff options
author | Keith Short <keithshort@chromium.org> | 2022-09-14 17:38:44 -0600 |
---|---|---|
committer | Chromeos LUCI <chromeos-scoped@luci-project-accounts.iam.gserviceaccount.com> | 2022-09-15 19:24:24 +0000 |
commit | 149d6814a7ffb7969098891fb550c820eca8f319 (patch) | |
tree | 075aee7449a0b812b9535001ee6402d87debc99c /driver | |
parent | 85bf6634783828083f3e36313640053b86841f1c (diff) | |
download | chrome-ec-149d6814a7ffb7969098891fb550c820eca8f319.tar.gz |
usb_mux: fix NULL checks in the usb_mux_chain
Some boards (servo_v4p1) don't assign mux devices to all type-c ports.
Ensure the mux device is valid before performing mux operations.
BUG=b:246828811
BRANCH=none
TEST=make buildall -j
Signed-off-by: Keith Short <keithshort@chromium.org>
Change-Id: I009593d4ee94d412c6068588121b77af18402ba6
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3897790
Reviewed-by: Matthew Blecker <matthewb@chromium.org>
Code-Coverage: Zoss <zoss-cl-coverage@prod.google.com>
Diffstat (limited to 'driver')
-rw-r--r-- | driver/usb_mux/usb_mux.c | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/driver/usb_mux/usb_mux.c b/driver/usb_mux/usb_mux.c index a3cd6e2c99..1edcf25179 100644 --- a/driver/usb_mux/usb_mux.c +++ b/driver/usb_mux/usb_mux.c @@ -273,7 +273,7 @@ static int configure_mux(int port, int index, enum mux_config_type config, * to make sure they are all updated appropriately. */ for (mux_chain = &usb_muxes[port]; - rv == EC_SUCCESS && mux_chain != NULL; + rv == EC_SUCCESS && mux_chain != NULL && mux_chain->mux != NULL; mux_chain = mux_chain->next, chip++) { mux_state_t lcl_state; const struct usb_mux *mux_ptr = mux_chain->mux; @@ -667,7 +667,7 @@ int usb_mux_retimer_fw_update_port_info(void) for (i = 0; i < CONFIG_USB_PD_PORT_MAX_COUNT; i++) { mux_chain = &usb_muxes[i]; - while (mux_chain) { + while (mux_chain && mux_chain->mux) { mux_ptr = mux_chain->mux; if (mux_ptr->driver && mux_ptr->driver->is_retimer_fw_update_capable && @@ -702,7 +702,7 @@ static void usb_mux_reset_in_g3(void) for (port = 0; port < board_get_usb_pd_port_count(); port++) { mux_chain = &usb_muxes[port]; - while (mux_chain) { + while (mux_chain && mux_chain->mux) { mux_ptr = mux_chain->mux; if (mux_ptr->flags & USB_MUX_FLAG_RESETS_IN_G3) { atomic_clear_bits(&flags[port], |