{
int ret = -1;
- if (system_data)
- free(system_data);
-
// BATTERY LOW/FULL
device_remove_callback(DEVICE_CALLBACK_BATTERY_LEVEL, device_system_cb);
// BATTERY CHARGING/NOT-CHARGING
if (ret != BT_ERROR_NONE)
ERROR("ret == %d", ret);
- ret = wifi_manager_deinitialize(system_data->wifi);
- if (ret != WIFI_MANAGER_ERROR_NONE)
- ERROR("ret == %d", ret);
- system_data->wifi = NULL;
+ if (system_data) {
+ if (system_data->wifi) {
+ ret = wifi_manager_deinitialize(system_data->wifi);
+ if (ret != WIFI_MANAGER_ERROR_NONE)
+ ERROR("wifi ret == %d", ret);
+ }
+
+ system_data->wifi = NULL;
+ free(system_data);
+ }
return;
}