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 C99333BE175; Sat, 30 May 2026 18:15:53 +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=1780164954; cv=none; b=fvnsP131EAnNEf5tzZ268fvZ8j0xBYkvX64SkVunWOFvx1E/5/YCurjglx8vSsLp1w7wFKxnUoie7y0Kg+iJboT+jUR64/cSTY8J2YwZmvRWak5MqcfBS+078VwJJlYEJuirAwpmq1lcs/3ZDYyL8PSIPun+Tx+dqiIF4pqaNO0= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780164954; c=relaxed/simple; bh=QGC2er1p2hFpw9w1gR2PF3IYsHweEUwtuDUOZdl9IAk=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=c9Eqhn/8rDXez09NLN3W9pvpcgJthcmaOWcINh8TrZbNw2mpfKmzKfSeMlcJbEsbviDe2YS0swfhms75pnhK/+n6DJOFGFsP5rYbvUYRqG+0a7FDy+r4I+oa6klA2lMP8u7gmR9FVXshLAi+Q35SkyewpcyT9n6KYctm3Rv2F10= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=i5+3nlwP; 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="i5+3nlwP" Received: by smtp.kernel.org (Postfix) with ESMTPSA id C1F051F00893; Sat, 30 May 2026 18:15:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1780164953; bh=2x5CtFsgTuGkF8V6HRLU+fdSr6kb3S4biDRcWdRxYo8=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=i5+3nlwPP6O3ZKxUZeeX2KUeT35+JyKZydluqedDYqSSOCDYw4XZXqeIlz4wO5qve jKrvyxhInfWVRXPj9vE0hZ29Xb8m/mbxegeKsYh+MsP4PqRu1sp4NOvwbty2Eq5Lrf ovh9BjAhmhwl2hyKOia8apNRt1uhASH7MbyIHWS0= 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 5.15 707/776] batman-adv: clear current gateway during teardown Date: Sat, 30 May 2026 18:07:01 +0200 Message-ID: <20260530160258.118825730@linuxfoundation.org> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260530160240.228940103@linuxfoundation.org> References: <20260530160240.228940103@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 5.15-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 @@ -478,10 +478,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);