diff --git a/drivers/usb/typec/class.c b/drivers/usb/typec/class.c index 91d62276b56f..7ab5c5125212 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_MAX)) return; port->pwr_opmode = opmode; diff --git a/include/linux/usb/typec.h b/include/linux/usb/typec.h index 894798084319..54563b881878 100644 --- a/include/linux/usb/typec.h +++ b/include/linux/usb/typec.h @@ -53,6 +53,7 @@ enum typec_pwr_opmode { TYPEC_PWR_MODE_1_5A, TYPEC_PWR_MODE_3_0A, TYPEC_PWR_MODE_PD, + TYPEC_PWR_MODE_MAX = TYPEC_PWR_MODE_PD, }; enum typec_accessory {