summaryrefslogtreecommitdiff
path: root/common/usbc/usb_pe_drp_sm.c
diff options
context:
space:
mode:
Diffstat (limited to 'common/usbc/usb_pe_drp_sm.c')
-rw-r--r--common/usbc/usb_pe_drp_sm.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/common/usbc/usb_pe_drp_sm.c b/common/usbc/usb_pe_drp_sm.c
index b3e51c6966..2f7f83f423 100644
--- a/common/usbc/usb_pe_drp_sm.c
+++ b/common/usbc/usb_pe_drp_sm.c
@@ -8158,8 +8158,15 @@ const uint32_t *const pd_get_src_caps(int port)
void pd_set_src_caps(int port, int cnt, uint32_t *src_caps)
{
+ const int limit = ARRAY_SIZE(pe[port].src_caps);
int i;
+ if (cnt > limit) {
+ CPRINTS("C%d: Trim PDOs (%d) exceeding limit (%d)", port, cnt,
+ limit);
+ cnt = limit;
+ }
+
pe[port].src_cap_cnt = cnt;
for (i = 0; i < cnt; i++)