From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wr1-f44.google.com (mail-wr1-f44.google.com [209.85.221.44]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id CE70D3BBA01 for ; Tue, 4 Aug 2026 08:26:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.44 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785831998; cv=none; b=DdQAtkzqcjnNt13f8du/Sinfs5lR9ZfwD36hCqaxjR+iYLhshrA1WCr2z+clBUGykyh1djWD9Flmbfa0JLlvd+razsglXErrBF5mwRLY1D96ktaa2Q7ir7Q6JrLOOSKCgJ9i+IBJei70v9ONVXVQ4fC2QkegE8SeDICOqlG0oFA= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785831998; c=relaxed/simple; bh=BQFteY2voHYMLFunRJz6Ll4QfFexNagrrLETSu9A++A=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=TnESqkKFfNHr8cGpQrTPkqHHM9Dg8axcb5meeELga9hthiRCasNFr0C3rQdVKtcDzLnQuKY920dFTN3DNr7XqjMNF9kZ5nlpbUX9XT7NUi186AkGiftZ5KYsBFPPFoKOhFSkamNotVoaTl2n2v7k6MKkCSOukNnX5/KAPYqBzhI= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=GrQm4wNf; arc=none smtp.client-ip=209.85.221.44 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="GrQm4wNf" Received: by mail-wr1-f44.google.com with SMTP id ffacd0b85a97d-4765eec32e1so205527f8f.1 for ; Tue, 04 Aug 2026 01:26:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1785831991; x=1786436791; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to:content-type; bh=BgISVsIsIFnGhLp1EYAeC2svf5amhtNd1DkilnWeLAo=; b=GrQm4wNf8ao6NW+nQP9EpWQfiDuiUEVfVWLGxm3gNqOp4x4BRMxI79Rdt+/WqEf5ST E3BP1D4OSoe22NvdGtDwaWDoKzZaYPeeLLYas+dFDuRs9mFRt/lpXziYMoRKr+QA7Vad n2upo4qC2xQ1h4YqVWlG452J6dPXvoQrSoH8ZOgBiIHG/4kwz1c4pIpl9XsnwgiaySUb 9Z7TqJ4AOIYzpvCFwYDBqbr7ceXCV0Mb5efY7WuVmcpUjbNQrn+SxePG4wm2sReoyVAe n49X8ld2RFbjlUBrqS59VI20SiaxJM/12tPxbAFC2r61eOROgpNlL6QQdrrZLkmZeDpw kuNg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1785831991; x=1786436791; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to:content-type; bh=BgISVsIsIFnGhLp1EYAeC2svf5amhtNd1DkilnWeLAo=; b=HQyDJFjcSxLrDWDLCG0EkJSdBPGUBYmrrxFT+rmgRaLFWkm0SESphy8C1D5JmhOF14 cfYrgiBgAE8W8JMvUPX6FH9vXI7ReumYKUH5gcmNmuidQX1hiCT1hgRtuxMtasebVN7V rW6x1JmXs0SyIWA2NLCZNrDQUIACKldA5Vr186WVSODZxKdRE4sdn9fsCNfcSYT9Uajy TZRg222+kYFK7v/8WJhwIvnEoeEYUD5A3KgBtTOdJDPIeJXlls3/8qsQbfaZ3JHtHNXs +R5H34whRKSw3pgEBYiDLWtCN73aLTJJJWQHwzLmWDHR0mRYRx9L+ifO/bwxzaFCEasB Hl2g== X-Forwarded-Encrypted: i=1; AHgh+RohrmSSd12Om081Pt0TCQZoZ1SczrOlf3D9bQzlPNdqxygtWOOkXIot5YMBYOMBdSpmTapqgZZdD0GhSPQ=@vger.kernel.org X-Gm-Message-State: AOJu0YxlVFN3iXRxl3290bFmVAkIfMfcp0DIwlx8IXYGQY4iMu744XTb RV0Z0hgvckgDJoV/978EybMwojzZ90Ng3DpY7Zsb2jrsVRDWuVOGc6R7 X-Gm-Gg: AR+sD116gNbxtcukeQeOm8e6RMMy5H43UbzvmQWvkBny+cpWYNGqYSODFikCwy9SX1Q RYMSrp4kDHBeMdwLKolqKaey+d6EwhnFLOHf2hMW7FZDYb4rEfxYn8JbrwNm1ZZWtpsSr1u+H7f 9TTNWQ5XQl6ciw5WdJfGoa4HxurZEgWOAMUQ8vvwJVM3H/ubWVgtj0hCwKGC1TmmORPxz8Q2Kjb fmLrDC/DTTsrEwvX11WmP7Cv+8dLeJEQHt+0e/W3XXYEkqmBuIWf5qN6lbdCDfRDPZqCwY6AqTw fW2+0kg/BIuVcmbMyvaVxc6hOIEBUmWhYbD6SeMTqITGJuTPTDVAY5rKoE1G9+FRqi/ib4myIfv uucGsZdKUXWBUS0ATDEPb/BCu38E+kpkCWY3ujrWeEDFjibWlTzzhqk1w+ScdwYe8nMXH+IWWfm MlhIYSsL2hL3NPMFH77XzIH+/eXhfg4ZAR7m1NS3czLu1A2oKH3AWePi9PNNbpAaIXZrnkXg4p+ FWgyFIN/0ID7JZP9O1i+OutlAPGsG585i4hiRoAd3AoXsAq/VlB0BFP6g== X-Received: by 2002:a05:600c:5252:b0:493:f42e:1b3f with SMTP id 5b1f17b1804b1-4980c6a4284mr152228175e9.3.1785831990958; Tue, 04 Aug 2026 01:26:30 -0700 (PDT) Received: from thomas-precision3591.paris.inria.fr (wifi-pro-82-131.paris.inria.fr. [128.93.82.131]) by smtp.googlemail.com with ESMTPSA id 5b1f17b1804b1-49807b9441csm300528555e9.4.2026.08.04.01.26.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 04 Aug 2026 01:26:30 -0700 (PDT) From: Thomas Fourier To: Cc: Thomas Fourier , =?UTF-8?q?Toke=20H=C3=B8iland-J=C3=B8rgensen?= , Kalle Valo , linux-wireless@vger.kernel.org (open list:QUALCOMM ATHEROS ATH9K WIRELESS DRIVER), linux-kernel@vger.kernel.org (open list) Subject: [PATCH net] wifi: ath9k: Fix potential spin_lock() before spin_lock_init() Date: Tue, 4 Aug 2026 10:09:08 +0200 Message-ID: <20260804080913.67985-2-fourier.thomas@gmail.com> X-Mailer: git-send-email 2.43.0 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit The function ath9k_init_wmi() initializes wmi->wmi_lock. It is called in ath9k_htc_probe_device(), and the priv->initialized flag is set. However, the ath9k_wmi_event_tasklet takes the lock before checking the priv->initialized flag, so the lock may not be initialized before being taken. This could be the case, for example, if the spin_lock_init() is reordered with tasklet_setup() in ath9k_init_wmi() by the compiler or CPU. There is a write memory barrier before setting the priv->initialized, but no corresponding read memory barrier is used after checking the flag. Move priv->initialized at the start of ath9k_wmi_event_tasklet() and add a corresponding read memory barrier. Fixes: 24355fcb0d4c ("wifi: ath9k: delay all of ath9k_wmi_event_tasklet() until init is complete") Signed-off-by: Thomas Fourier --- drivers/net/wireless/ath/ath9k/wmi.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/drivers/net/wireless/ath/ath9k/wmi.c b/drivers/net/wireless/ath/ath9k/wmi.c index 284e8c13b043..df4a3a625536 100644 --- a/drivers/net/wireless/ath/ath9k/wmi.c +++ b/drivers/net/wireless/ath/ath9k/wmi.c @@ -146,6 +146,15 @@ void ath9k_wmi_event_tasklet(struct tasklet_struct *t) unsigned long flags; u16 cmd_id; + /* Check if ath9k_htc_probe_device() completed. */ + if (!data_race(priv->initialized)) + return; + /* + * Make sure ath9k_htc_probe_device() initialization is + * committed to memory before processing skb. + */ + smp_rmb(); + do { spin_lock_irqsave(&wmi->wmi_lock, flags); skb = __skb_dequeue(&wmi->wmi_event_queue); @@ -155,12 +164,6 @@ void ath9k_wmi_event_tasklet(struct tasklet_struct *t) } spin_unlock_irqrestore(&wmi->wmi_lock, flags); - /* Check if ath9k_htc_probe_device() completed. */ - if (!data_race(priv->initialized)) { - kfree_skb(skb); - continue; - } - hdr = (struct wmi_cmd_hdr *) skb->data; cmd_id = be16_to_cpu(hdr->command_id); wmi_event = skb_pull(skb, sizeof(struct wmi_cmd_hdr)); -- 2.43.0