mirror of
https://github.com/espressif/esp-idf.git
synced 2024-10-05 20:47:46 -04:00
fix(esp_hw_support): fix acessing array bellow bounds
This commit is contained in:
parent
a262e879d1
commit
5737ba06c3
@ -55,18 +55,22 @@ static clkout_channel_handle_t* clkout_channel_alloc(soc_clkout_sig_id_t clk_sig
|
|||||||
clkout_channel_handle_t *allocated_channel = NULL;
|
clkout_channel_handle_t *allocated_channel = NULL;
|
||||||
|
|
||||||
#if SOC_GPIO_CLOCKOUT_BY_IO_MUX
|
#if SOC_GPIO_CLOCKOUT_BY_IO_MUX
|
||||||
portENTER_CRITICAL(&s_clkout_handle[IONUM_TO_CLKOUT_CHANNEL(gpio_num)].clkout_channel_lock);
|
int32_t channel_num = IONUM_TO_CLKOUT_CHANNEL(gpio_num);
|
||||||
if (!s_clkout_handle[IONUM_TO_CLKOUT_CHANNEL(gpio_num)].is_mapped) {
|
if (channel_num < 0) {
|
||||||
s_clkout_handle[IONUM_TO_CLKOUT_CHANNEL(gpio_num)].is_mapped = true;
|
return NULL;
|
||||||
allocated_channel = &s_clkout_handle[IONUM_TO_CLKOUT_CHANNEL(gpio_num)];
|
}
|
||||||
} else if ((s_clkout_handle[IONUM_TO_CLKOUT_CHANNEL(gpio_num)].mapped_io_bmap & BIT(gpio_num)) &&
|
portENTER_CRITICAL(&s_clkout_handle[channel_num].clkout_channel_lock);
|
||||||
(s_clkout_handle[IONUM_TO_CLKOUT_CHANNEL(gpio_num)].mapped_clock == clk_sig)) {
|
if (!s_clkout_handle[channel_num].is_mapped) {
|
||||||
allocated_channel = &s_clkout_handle[IONUM_TO_CLKOUT_CHANNEL(gpio_num)];
|
s_clkout_handle[channel_num].is_mapped = true;
|
||||||
|
allocated_channel = &s_clkout_handle[channel_num];
|
||||||
|
} else if ((s_clkout_handle[channel_num].mapped_io_bmap & BIT(gpio_num)) &&
|
||||||
|
(s_clkout_handle[channel_num].mapped_clock == clk_sig)) {
|
||||||
|
allocated_channel = &s_clkout_handle[channel_num];
|
||||||
}
|
}
|
||||||
if (allocated_channel != NULL) {
|
if (allocated_channel != NULL) {
|
||||||
allocated_channel->channel_id = (clock_out_channel_t)IONUM_TO_CLKOUT_CHANNEL(gpio_num);
|
allocated_channel->channel_id = (clock_out_channel_t)channel_num;
|
||||||
}
|
}
|
||||||
portEXIT_CRITICAL(&s_clkout_handle[IONUM_TO_CLKOUT_CHANNEL(gpio_num)].clkout_channel_lock);
|
portEXIT_CRITICAL(&s_clkout_handle[channel_num].clkout_channel_lock);
|
||||||
#elif SOC_GPIO_CLOCKOUT_BY_GPIO_MATRIX
|
#elif SOC_GPIO_CLOCKOUT_BY_GPIO_MATRIX
|
||||||
for (uint32_t channel = 0; channel < CLKOUT_CHANNEL_MAX; channel++) {
|
for (uint32_t channel = 0; channel < CLKOUT_CHANNEL_MAX; channel++) {
|
||||||
portENTER_CRITICAL(&s_clkout_handle[channel].clkout_channel_lock);
|
portENTER_CRITICAL(&s_clkout_handle[channel].clkout_channel_lock);
|
||||||
|
Loading…
Reference in New Issue
Block a user