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 58C42471240; Tue, 21 Jul 2026 17:55:08 +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=1784656509; cv=none; b=kQEiSCI9rwM/1p60YYQCEvCUQXyslFH1nq4kRXHC25eYLYxwStR9DypdWrWAq1H7bY5cr63cQpfXI0arnj+4kr74WQV2mS3Y0oaeJB6F/RQZ/36Tt4uMvpbBv1pdNdY0eJOFXO0os+uZFgIFdOeGMhPJebajvhE7hfmJDlTOO6w= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784656509; c=relaxed/simple; bh=/teD8Qu1wnJki7nITYCoC+jLSiepyeNSvTmeeNtH2bE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=S+rJ8/tPT5ep7OaQZziMaZM1kFtk0AdSeNA4p6ESpBjcy8OLH2iqfpozEGuuEKfyqDb0noeFiHZnDtng6P0qNnddWD9C6KO5B0xjeHVpGAFXthbWKtOUFgGjn3u1lTFRIvXYMJxIpjS4kHdwN3xp6FzCoUuRqQUD62wau2LFoLo= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=BorlZVZK; 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="BorlZVZK" Received: by smtp.kernel.org (Postfix) with ESMTPSA id BCC731F000E9; Tue, 21 Jul 2026 17:55:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1784656508; bh=iZEJ5CubnH1CqP6+yXt7OmO2oisRJZp+c/80UjCAA+o=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=BorlZVZK1W2TYWGizMSHDoKFTUH4vPNGXt0OlfC1sq4DuZ/1UEIyQAJfHsBasWdQ6 3FifdcTUe4VQETi/UkuYNczYt2anBSAB6OHd+dsRsve0N5PeYt/EU4ZfHtIlcrIHQD sbO1v0HTEsfBFXCFHwODS7abZA7j+ZEkXdQsA+QI= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Ryder Lee , Felix Fietkau , Sasha Levin Subject: [PATCH 6.18 0412/1611] wifi: mt76: mt7915: fix potential tx_retries underflow Date: Tue, 21 Jul 2026 17:08:48 +0200 Message-ID: <20260721152524.520570590@linuxfoundation.org> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260721152514.750365251@linuxfoundation.org> References: <20260721152514.750365251@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.18-stable review patch. If anyone has any objections, please let me know. ------------------ From: Ryder Lee [ Upstream commit 05e72b6167970043348bfbe8f72a3b67a38a9f1c ] When FIELD_GET returns 0 for the retry count, subtracting 1 causes an unsigned integer underflow, resulting in tx_retries becoming a very large value (0xFFFFFFFF for u32). Fix by checking if count is non-zero before subtracting 1. Fixes: 943e4fb96e6f ("wifi: mt76: mt7915: report tx retries/failed counts for non-WED path") Signed-off-by: Ryder Lee Link: https://patch.msgid.link/20260605113306.3485554-1-ryder.lee@mediatek.com Signed-off-by: Felix Fietkau Signed-off-by: Sasha Levin --- drivers/net/wireless/mediatek/mt76/mt7915/mac.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/drivers/net/wireless/mediatek/mt76/mt7915/mac.c b/drivers/net/wireless/mediatek/mt76/mt7915/mac.c index 9364e8673eb9de..50af0d9f240b6e 100644 --- a/drivers/net/wireless/mediatek/mt76/mt7915/mac.c +++ b/drivers/net/wireless/mediatek/mt76/mt7915/mac.c @@ -912,16 +912,16 @@ mt7915_mac_tx_free(struct mt7915_dev *dev, void *data, int len) } if (!mtk_wed_device_active(&mdev->mmio.wed) && wcid) { - u32 tx_retries = 0, tx_failed = 0; + u32 tx_retries = 0, tx_failed = 0, count; if (v3 && (info & MT_TX_FREE_MPDU_HEADER_V3)) { - tx_retries = - FIELD_GET(MT_TX_FREE_COUNT_V3, info) - 1; + count = FIELD_GET(MT_TX_FREE_COUNT_V3, info); + tx_retries = count ? count - 1 : 0; tx_failed = tx_retries + !!FIELD_GET(MT_TX_FREE_STAT_V3, info); } else if (!v3 && (info & MT_TX_FREE_MPDU_HEADER)) { - tx_retries = - FIELD_GET(MT_TX_FREE_COUNT, info) - 1; + count = FIELD_GET(MT_TX_FREE_COUNT, info); + tx_retries = count ? count - 1 : 0; tx_failed = tx_retries + !!FIELD_GET(MT_TX_FREE_STAT, info); } -- 2.53.0