From bcd8b7cffbde9f20dc337a2ec991e49031eaf695 Mon Sep 17 00:00:00 2001 From: Patrick Georgi Date: Mon, 9 Sep 2019 23:04:40 +0200 Subject: 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 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1793586 Reviewed-by: Daisuke Nojiri Tested-by: Patrick Georgi Commit-Queue: Patrick Georgi --- board/glkrvp/chg_usb_pd.c | 16 ++++++---------- 1 file 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. -- cgit v1.2.1