Skip to content

Commit 6c2a3b8

Browse files
Fix crash in nrf70_bm_rt_init
Fix a crash if the chan_info element of reg_info parameter being passed to nrf70_bm_rt_init is not initialized to a non NULL value. This is not necessary and can be managed withing the library API. Signed-off-by: Sachin D Kulkarni <Sachin.Kulkarni@nordicsemi.no>
1 parent 9cf2db3 commit 6c2a3b8

File tree

4 files changed

+5
-28
lines changed

4 files changed

+5
-28
lines changed

nrf70_bm_lib/source/radio_test/nrf70_bm_lib.c

+4-4
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ int nrf70_bm_rt_init(struct nrf70_bm_regulatory_info *reg_info)
3030
goto deinit;
3131
}
3232

33-
ret = nrf70_bm_rt_fmac_get_reg(&reg_info_curr);
33+
ret = nrf70_bm_rt_get_reg(&reg_info_curr);
3434
if (ret) {
3535
NRF70_LOG_ERR("Failed to get regulatory info");
3636
goto deinit;
@@ -48,17 +48,17 @@ int nrf70_bm_rt_init(struct nrf70_bm_regulatory_info *reg_info)
4848
goto deinit;
4949
}
5050

51-
memset(reg_info->chan_info,
51+
memset(reg_info_curr.chan_info,
5252
0,
5353
sizeof(struct nrf70_bm_reg_chan_info) * NRF70_MAX_CHANNELS);
5454

55-
ret = nrf70_bm_rt_get_reg(reg_info);
55+
ret = nrf70_bm_rt_get_reg(&reg_info_curr);
5656
if (ret) {
5757
printf("Failed to get regulatory info: %d\n", ret);
5858
return -1;
5959
}
6060

61-
printf("Regulatory country code set to: %s\n", reg_info->country_code);
61+
printf("Regulatory country code set to: %s\n", reg_info_curr.country_code);
6262
}
6363
return 0;
6464
deinit:

nrf70_bm_lib/source/system/nrf70_bm_lib.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ int nrf70_bm_sys_init(uint8_t *mac_addr,
116116
sizeof(struct nrf70_bm_reg_chan_info) *
117117
NRF70_MAX_CHANNELS);
118118

119-
ret = nrf70_bm_sys_fmac_get_reg(&reg_info_curr);
119+
ret = nrf70_bm_sys_get_reg(&reg_info_curr);
120120
if (ret) {
121121
NRF70_LOG_ERR("Failed to get regulatory info");
122122
goto deinit;

samples/radio_test_bm/src/nrf_wifi_radio_test_main.c

-11
Original file line numberDiff line numberDiff line change
@@ -34,13 +34,6 @@ int main(void)
3434
memcpy(reg_info.country_code, CONFIG_WIFI_RT_REG_DOMAIN, 2);
3535
reg_info.force = true;
3636

37-
reg_info.chan_info = malloc(sizeof(struct nrf70_bm_reg_chan_info) * NRF70_MAX_CHANNELS);
38-
if (!reg_info.chan_info) {
39-
printf("Failed to allocate memory for regulatory info\n");
40-
ret = -ENOMEM;
41-
goto cleanup;
42-
}
43-
4437
/* Initialize the Wi-Fi module */
4538
CHECK_RET(nrf70_bm_rt_init(&reg_info));
4639
printf("Initialized WiFi module, ready for radio test\n");
@@ -52,10 +45,6 @@ int main(void)
5245
}
5346

5447
cleanup:
55-
if (reg_info.chan_info) {
56-
free(reg_info.chan_info);
57-
}
58-
5948
if (ret) {
6049
nrf70_bm_rt_deinit();
6150
printf("Exiting WiFi radio test sample application with error: %d\n", ret);

samples/scan_rt_bm/src/main.c

-12
Original file line numberDiff line numberDiff line change
@@ -226,13 +226,6 @@ int main(void)
226226
int ret = -1;
227227
int i;
228228

229-
reg_info.chan_info = malloc(sizeof(struct nrf70_bm_reg_chan_info) * NRF70_MAX_CHANNELS);
230-
if (!reg_info.chan_info) {
231-
printf("Failed to allocate memory for regulatory info\n");
232-
ret = -ENOMEM;
233-
goto cleanup;
234-
}
235-
236229
for (i = 0; i < 2; i++) {
237230
/*
238231
* Radio test operation
@@ -318,11 +311,6 @@ int main(void)
318311

319312
ret = 0;
320313
cleanup:
321-
if (reg_info.chan_info) {
322-
free(reg_info.chan_info);
323-
reg_info.chan_info = NULL;
324-
}
325-
326314
if (sys_init) {
327315
nrf70_bm_sys_deinit();
328316
sys_init = false;

0 commit comments

Comments
 (0)