usb_tc_drp_acc_trysrc_sm: add bound check
Bound dynamic pd port number with CONFIG_USB_PD_PORT_MAX_COUNT to
prevent memory corruption.
BRANCH=none
TEST=make -j buildall
LOW_COVERAGE_REASON=No unit test infrastructure for this module
@@ -1561,6 +1561,9 @@ void tc_state_init(int port)
{
enum usb_tc_state first_state;
+ if (port >= CONFIG_USB_PD_PORT_MAX_COUNT)
+ return;
+
/* For test builds, replicate static initialization */
if (IS_ENABLED(TEST_BUILD)) {
memset(&tc[port], 0, sizeof(tc[port]));
