nl80211: Fix handling of if_indices reallocation failure

Addition of a separate if_indices_reason array broke reallocation
failure checking. drv->if_indices or drv->if_indices_reason could not be
NULL in the place where this check was moved to. Fix that by maintaining
knowledge of reallocation failure in a separate local variable.

Fixes: 732b1d20ec ("nl80211: Clean up ifidx properly if interface in a bridge is removed")
Signed-off-by: Jouni Malinen <j@w1.fi>
This commit is contained in:
Jouni Malinen 2019-04-28 20:52:10 +03:00
parent b93a0ce7bd
commit e6ca2f1139

View file

@ -6641,6 +6641,7 @@ static void add_ifidx(struct wpa_driver_nl80211_data *drv, int ifidx,
{
int i;
int *old, *old_reason;
int alloc_failed = 0;
wpa_printf(MSG_DEBUG,
"nl80211: Add own interface ifindex %d (ifidx_reason %d)",
@ -6679,14 +6680,16 @@ static void add_ifidx(struct wpa_driver_nl80211_data *drv, int ifidx,
drv->if_indices = drv->default_if_indices;
else
drv->if_indices = old;
alloc_failed = 1;
}
if (!drv->if_indices_reason) {
if (!old_reason)
drv->if_indices_reason = drv->default_if_indices_reason;
else
drv->if_indices_reason = old_reason;
alloc_failed = 1;
}
if (!drv->if_indices || !drv->if_indices_reason) {
if (alloc_failed) {
wpa_printf(MSG_ERROR, "Failed to reallocate memory for "
"interfaces");
wpa_printf(MSG_ERROR, "Ignoring EAPOL on interface %d", ifidx);