Skip to content

Commit 8ff9488

Browse files
committed
resolve RTWInterface initialization run after error issue
1 parent ea36c62 commit 8ff9488

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

targets/TARGET_Realtek/TARGET_AMEBA/RTWInterface.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,12 +93,14 @@ RTWInterface::RTWInterface()
9393

9494
emac = wlan_emac_init_interface();
9595
if (!emac) {
96-
printf("Error init RTWInterface!\r\n");
96+
printf("Error init RTWInterface!\r\n");
97+
return;
9798
}
9899
emac->ops.power_up(emac);
99100
ret = mbed_lwip_init(emac);
100101
if (ret != 0) {
101102
printf("Error init RTWInterface!(%d)\r\n", ret);
103+
return;
102104
}
103105
}
104106

targets/TARGET_Realtek/TARGET_AMEBA/rtw_emac.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -218,6 +218,10 @@ emac_interface_t *wlan_emac_init_interface()
218218

219219
if (_emac == NULL) {
220220
_emac = new emac_interface_t();
221+
if (_emac == NULL) {//new emac_interface_t fail
222+
printf("emac initialization failed\r\n");
223+
return NULL;
224+
}
221225
_emac->hw = NULL;
222226
memcpy((void*)&_emac->ops, &wlan_emac_interface, sizeof(wlan_emac_interface));
223227
}

0 commit comments

Comments
 (0)