diff --git a/drivers/usb/typec/class.c b/drivers/usb/typec/class.c index 91d62276b56f..ab469b52503a 100644 --- a/drivers/usb/typec/class.c +++ b/drivers/usb/typec/class.c @@ -1369,7 +1369,8 @@ void typec_set_pwr_opmode(struct typec_port *port, { struct device *partner_dev; - if (port->pwr_opmode == opmode) + if ((port->pwr_opmode == opmode) || (opmode < TYPEC_PWR_MODE_USB) || + (opmode > TYPEC_PWR_MODE_PD)) return; port->pwr_opmode = opmode;