From e6ca2f1139b35671b963aa169d6ebda75073e705 Mon Sep 17 00:00:00 2001 From: Jouni Malinen Date: Sun, 28 Apr 2019 20:52:10 +0300 Subject: [PATCH] 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: 732b1d20ec06 ("nl80211: Clean up ifidx properly if interface in a bridge is removed") Signed-off-by: Jouni Malinen --- src/drivers/driver_nl80211.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/drivers/driver_nl80211.c b/src/drivers/driver_nl80211.c index 5da8a793b..ab2bdaf83 100644 --- a/src/drivers/driver_nl80211.c +++ b/src/drivers/driver_nl80211.c @@ -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);