@@ -121,9 +121,8 @@ static void cyw43_sleep_timeout_reached(async_context_t *context, __unused async
121121
122122bool cyw43_driver_init (async_context_t * context ) {
123123#if CYW43_USE_PARTITION_FIRMWARE
124- const int buf_words = (16 * 4 ) + 1 ; // maximum of 16 partitions, each with maximum of 4 words returned, plus 1
125- uint32_t * buffer = malloc (buf_words * 4 );
126- int ret = rom_get_partition_table_info (buffer , buf_words , PT_INFO_PARTITION_LOCATION_AND_FLAGS | PT_INFO_PARTITION_ID );
124+ uint32_t buffer [(16 * 4 ) + 1 ] = {}; // maximum of 16 partitions, each with maximum of 4 words returned, plus 1
125+ int ret = rom_get_partition_table_info (buffer , count_of (buffer ), PT_INFO_PARTITION_LOCATION_AND_FLAGS | PT_INFO_PARTITION_ID );
127126
128127 assert (buffer [0 ] == (PT_INFO_PARTITION_LOCATION_AND_FLAGS | PT_INFO_PARTITION_ID ));
129128
@@ -141,6 +140,7 @@ bool cyw43_driver_init(async_context_t *context) {
141140 id |= ((uint64_t )(buffer [i ++ ]) << 32ull );
142141 if (id == CYW43_WIFI_FW_PARTITION_ID ) {
143142 picked_p = p ;
143+ break ;
144144 }
145145 }
146146
@@ -162,7 +162,7 @@ bool cyw43_driver_init(async_context_t *context) {
162162 }
163163
164164 CYW43_DEBUG ("Chosen CYW43 firmware in partition %d\n" , picked_p );
165- int ret = rom_get_partition_table_info (buffer , buf_words , PT_INFO_PARTITION_LOCATION_AND_FLAGS | PT_INFO_SINGLE_PARTITION | (picked_p << 24 ));
165+ int ret = rom_get_partition_table_info (buffer , count_of ( buffer ) , PT_INFO_PARTITION_LOCATION_AND_FLAGS | PT_INFO_SINGLE_PARTITION | (picked_p << 24 ));
166166 assert (buffer [0 ] == (PT_INFO_PARTITION_LOCATION_AND_FLAGS | PT_INFO_SINGLE_PARTITION ));
167167 assert (ret == 3 );
168168
@@ -179,9 +179,7 @@ bool cyw43_driver_init(async_context_t *context) {
179179 cyw43_clm_len = * (uint32_t * )(XIP_NOCACHE_NOALLOC_NOTRANSLATE_BASE + saddr + 4 );
180180 fw_data = XIP_NOCACHE_NOALLOC_NOTRANSLATE_BASE + saddr + 8 ;
181181 }
182- free (buffer );
183182 } else {
184- free (buffer );
185183 CYW43_DEBUG ("No partition table, so cannot get firmware from partition - get_partition_table_info returned %d\n" , ret );
186184 return false;
187185 }
0 commit comments