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 3ACA530E853; Sat, 30 May 2026 17:31:41 +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=1780162304; cv=none; b=XYMBD7yI/HM6KKxZ8hoeaUBF/v8VBFcKzJHnSrUxZJHmHrfTR01iQMD8kHQ7z5VpjfEDFX3VeK3PiQEuB3wusqUCUa9BioMTVvc3fl8SiQvYlFWBQ4jHOCiVtwYTc4FM7OhxKrT1wZD4SnEHFurBWd63vd7bqXHPVVEqIOJBO48= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780162304; c=relaxed/simple; bh=5PJW3CEby3ZU2aQMmLNpMZ1FMFD8jV+N/KgDXHW1d5s=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=iDDaAbslWzZdKYWZhkmgw6kbzNCEpOdpUorwX9Ggryjx/1y+Dgo4FL4F8yA3eQTuBYnZRjt+X6k1sSmOGcVBfjHXQ+EDpYChrfh2gJM1DEa+9SkQ6ELR6LslLUoyyJQ/3kfMtYqSZWAzIRaeD2tMxA6lVb01BaIh7LK/3LWnhgM= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=pnCzvqnW; 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="pnCzvqnW" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 393AB1F00893; Sat, 30 May 2026 17:31:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1780162301; bh=6oMqNCKb/bUpXDKKO06gEIiG73N5m3GuZha3dnOtda4=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=pnCzvqnWvyF8P6gfBRLyqK9PlEnto6cRBheyBZyTciyd9qTWZ2YLDxWCvAmm+2qeO Jwax+gnSXiut2NHWZNT/zz/4n/Iy1HLOgOqlYvMwg8yI1rRUy8D64Eq9egWSxt5Vrm lQp2fntXSw9LGnWpsKBoXrmzdPaHOZSt9X/hiGiY= 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.1 881/969] batman-adv: clear current gateway during teardown Date: Sat, 30 May 2026 18:06:45 +0200 Message-ID: <20260530160325.017528042@linuxfoundation.org> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260530160300.485627683@linuxfoundation.org> References: <20260530160300.485627683@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.1-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);