From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 483D82E92BA; Thu, 28 May 2026 20:48:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780001294; cv=none; b=TgG+DQPGmC4KRdw6BR/eEM08ZG4s+Ne3JTXyYJUPwrYMN0DUSuT5kMvw84X8xkJhWjMRnVerSbxFEn3lPT2QJ2SeKdoRDU+QznBEgz9s7k+M86+ocb5oOy7s6QuyP7hWZ3+LEB2flN7riv4ggJXCxmKXKwobvDqZdBIT1r1by/U= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780001294; c=relaxed/simple; bh=JrfnjC76o38huNy6XkHKegeS2ETiqdyq0WCsAqMfltw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=kO4vR/3y3KBd8deaZCc+y/K97E1xngNiNdmu8nrs/5KLpXOEjX8a9uSRMfTfG43Gi8FpMF7PJOgFm81AKT0vDy2eyYUsO7e6D+9YWdrAPqVSAirDIjJViZKbtgzEFgXHU+jqToHT8BP4HHBvxUoHy6vu3QGMwMwusitckocwQdg= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=IpRmKHTu; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="IpRmKHTu" Received: by smtp.kernel.org (Postfix) with ESMTPSA id AA18D1F000E9; Thu, 28 May 2026 20:48:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1780001293; bh=JkrgEBk3ir76Yfg1ymyOLmuP/fBtGB2HBk2kxlOkzoI=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=IpRmKHTuUNr5m8zn5NhxpIinvLpZtR/Huq91LY2h2igcgTW6mzU8UfzJMAWkEHrHJ F/adSlifVX1/SJpDT14nZkzfh5JXLayGzrA0kpkbPhTRANjkqSPCJ6q7jy2oq2wc78 9FlxRezF7EVfBab93lxooMcchXVj3XJ/vs3PkZUc= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, stable@kernel.org, Yuan Tan , Yifan Wu , Juefei Pu , Xin Liu , Ruijie Li , Zhanpeng Li , Ren Wei , Sven Eckelmann Subject: [PATCH 6.6 077/186] batman-adv: clear current gateway during teardown Date: Thu, 28 May 2026 21:49:17 +0200 Message-ID: <20260528194931.015577005@linuxfoundation.org> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20260528194928.941004471@linuxfoundation.org> References: <20260528194928.941004471@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: stable@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.6-stable review patch. If anyone has any objections, please let me know. ------------------ From: Ruijie Li commit a340a51ed801eab7bb454150c226323b865263cc upstream. batadv_gw_node_free() removes the gateway list entries during mesh teardown, but it does not clear the currently selected gateway. This leaves stale gateway state behind across cleanup and can break a later mesh recreation. Clear bat_priv->gw.curr_gw before walking the gateway list so the selected gateway reference is dropped as part of teardown. Fixes: 2265c1410864 ("batman-adv: gateway election code refactoring") Cc: stable@kernel.org Reported-by: Yuan Tan Reported-by: Yifan Wu Reported-by: Juefei Pu Reported-by: Xin Liu Signed-off-by: Ruijie Li Signed-off-by: Zhanpeng Li Signed-off-by: Ren Wei Signed-off-by: Sven Eckelmann Signed-off-by: Greg Kroah-Hartman --- net/batman-adv/gateway_client.c | 4 ++++ 1 file changed, 4 insertions(+) --- a/net/batman-adv/gateway_client.c +++ b/net/batman-adv/gateway_client.c @@ -479,10 +479,14 @@ void batadv_gw_node_delete(struct batadv */ void batadv_gw_node_free(struct batadv_priv *bat_priv) { + struct batadv_gw_node *curr_gw; struct batadv_gw_node *gw_node; struct hlist_node *node_tmp; spin_lock_bh(&bat_priv->gw.list_lock); + curr_gw = rcu_replace_pointer(bat_priv->gw.curr_gw, NULL, true); + batadv_gw_node_put(curr_gw); + hlist_for_each_entry_safe(gw_node, node_tmp, &bat_priv->gw.gateway_list, list) { hlist_del_init_rcu(&gw_node->list);