400-terminate_on_setup_failure.patch 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. --- a/src/ap/hostapd.c
  2. +++ b/src/ap/hostapd.c
  3. @@ -1103,13 +1103,8 @@ int hostapd_setup_interface_complete(str
  4. size_t j;
  5. u8 *prev_addr;
  6. - if (err) {
  7. - wpa_printf(MSG_ERROR, "Interface initialization failed");
  8. - hostapd_set_state(iface, HAPD_IFACE_DISABLED);
  9. - if (iface->interfaces && iface->interfaces->terminate_on_error)
  10. - eloop_terminate();
  11. - return -1;
  12. - }
  13. + if (err)
  14. + goto error;
  15. wpa_printf(MSG_DEBUG, "Completing interface initialization");
  16. if (iface->conf->channel) {
  17. @@ -1140,7 +1135,7 @@ int hostapd_setup_interface_complete(str
  18. hapd->iconf->vht_oper_centr_freq_seg1_idx)) {
  19. wpa_printf(MSG_ERROR, "Could not set channel for "
  20. "kernel driver");
  21. - return -1;
  22. + goto error;
  23. }
  24. }
  25. @@ -1151,7 +1146,7 @@ int hostapd_setup_interface_complete(str
  26. hostapd_logger(hapd, NULL, HOSTAPD_MODULE_IEEE80211,
  27. HOSTAPD_LEVEL_WARNING,
  28. "Failed to prepare rates table.");
  29. - return -1;
  30. + goto error;
  31. }
  32. }
  33. @@ -1159,14 +1154,14 @@ int hostapd_setup_interface_complete(str
  34. hostapd_set_rts(hapd, hapd->iconf->rts_threshold)) {
  35. wpa_printf(MSG_ERROR, "Could not set RTS threshold for "
  36. "kernel driver");
  37. - return -1;
  38. + goto error;
  39. }
  40. if (hapd->iconf->fragm_threshold > -1 &&
  41. hostapd_set_frag(hapd, hapd->iconf->fragm_threshold)) {
  42. wpa_printf(MSG_ERROR, "Could not set fragmentation threshold "
  43. "for kernel driver");
  44. - return -1;
  45. + goto error;
  46. }
  47. prev_addr = hapd->own_addr;
  48. @@ -1176,7 +1171,7 @@ int hostapd_setup_interface_complete(str
  49. if (j)
  50. os_memcpy(hapd->own_addr, prev_addr, ETH_ALEN);
  51. if (hostapd_setup_bss(hapd, j == 0))
  52. - return -1;
  53. + goto error;
  54. if (hostapd_mac_comp_empty(hapd->conf->bssid) == 0)
  55. prev_addr = hapd->own_addr;
  56. }
  57. @@ -1191,7 +1186,7 @@ int hostapd_setup_interface_complete(str
  58. if (hostapd_driver_commit(hapd) < 0) {
  59. wpa_printf(MSG_ERROR, "%s: Failed to commit driver "
  60. "configuration", __func__);
  61. - return -1;
  62. + goto error;
  63. }
  64. /*
  65. @@ -1216,6 +1211,13 @@ int hostapd_setup_interface_complete(str
  66. iface->interfaces->terminate_on_error--;
  67. return 0;
  68. +
  69. +error:
  70. + wpa_printf(MSG_ERROR, "Interface initialization failed");
  71. + hostapd_set_state(iface, HAPD_IFACE_DISABLED);
  72. + if (iface->interfaces && iface->interfaces->terminate_on_error)
  73. + eloop_terminate();
  74. + return -1;
  75. }