diff options
author | Patrick Georgi <pgeorgi@google.com> | 2019-09-09 23:04:40 +0200 |
---|---|---|
committer | Commit Bot <commit-bot@chromium.org> | 2019-09-12 23:36:54 +0000 |
commit | bcd8b7cffbde9f20dc337a2ec991e49031eaf695 (patch) | |
tree | 654a7dbc80f16b0c900c1bcabde63848595aa74a /board/glkrvp | |
parent | f2086e771d940b35d86e5adcaf21ffe3035e71d2 (diff) | |
download | chrome-ec-bcd8b7cffbde9f20dc337a2ec991e49031eaf695.tar.gz |
board/glkrvp: Don't check for VBUS source on DC jack
That only leads to an array overflow in tcpc_read.
Found by Coverity Scan #152503
BUG=none
BRANCH=none
TEST=none
Change-Id: Iba729bed35ed456e76725cd6e02acadfef6967b7
Signed-off-by: Patrick Georgi <pgeorgi@google.com>
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1793586
Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org>
Tested-by: Patrick Georgi <pgeorgi@chromium.org>
Commit-Queue: Patrick Georgi <pgeorgi@chromium.org>
Diffstat (limited to 'board/glkrvp')
-rw-r--r-- | board/glkrvp/chg_usb_pd.c | 16 |
1 files changed, 6 insertions, 10 deletions
diff --git a/board/glkrvp/chg_usb_pd.c b/board/glkrvp/chg_usb_pd.c index cdab48d47b..2536c051c3 100644 --- a/board/glkrvp/chg_usb_pd.c +++ b/board/glkrvp/chg_usb_pd.c @@ -199,16 +199,12 @@ DECLARE_HOOK(HOOK_INIT, board_charge_init, HOOK_PRIO_DEFAULT); int board_set_active_charge_port(int port) { - /* charge port is a realy physical port */ - int is_real_port = (port >= 0 && - port < CHARGE_PORT_COUNT); - /* check if we are source vbus on that port */ - int source = board_charger_port_is_sourcing_vbus(port); - - if (is_real_port && source) { - CPRINTS("Skip enable p%d", port); - return EC_ERROR_INVAL; - } + /* if it's a PD port and sourcing VBUS, don't enable */ + if (port >= 0 && port < CONFIG_USB_PD_PORT_COUNT) + if (board_charger_port_is_sourcing_vbus(port)) { + CPRINTS("Skip enable p%d", port); + return EC_ERROR_INVAL; + } /* * Do not enable Type-C port if the DC Jack is present. |