From patchwork Wed Sep 11 07:43:03 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dan Carpenter X-Patchwork-Id: 13799846 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 4CD8BEDE998 for ; Wed, 11 Sep 2024 07:48:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Type:MIME-Version: Message-ID:Subject:Cc:To:From:Date:Reply-To:Content-Transfer-Encoding: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References:List-Owner; bh=As6Mh+lzj3Gz1WRcYQZrDI90Xpd0PmMaVKgj6FhuHj4=; b=Snx1KwKNDCeQiOzcuWQcv/HP3k 6KHYJ1SmO/Gh+5IDpJPRW0AN3cCDJvGAmgdSX+FIF6gRnbdgKRSJ3WBFfs/wXPw6FRSFj4ogLLiW2 pcZzf+B47FDRkZTEDHxMc8CmbbexWYk6yHjUq/99g5vxWQFl7gL/RmUQqPMAsF65hPVQsXsLv17fy PlugeqU0OS+Hq5p+UwoXg41iSuzuZt2uljNttmnflTmNIhrDAv9qDKH0E3o5MvyIlGJJTaLdj9ls0 Qx4o6iTnRBTQqqg25HT+78zPo8waecFQWdHvvGQze2l43FeQJhlFM3VAZK18pnwVgQfxZPHBLtJGK I7GMLZWw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1soI4u-00000008Vn0-15Or; Wed, 11 Sep 2024 07:47:52 +0000 Received: from mail-wr1-x42b.google.com ([2a00:1450:4864:20::42b]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1soI0K-00000008UqF-3EXH for linux-arm-kernel@lists.infradead.org; Wed, 11 Sep 2024 07:43:10 +0000 Received: by mail-wr1-x42b.google.com with SMTP id ffacd0b85a97d-374c3eef39eso3660226f8f.0 for ; Wed, 11 Sep 2024 00:43:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1726040587; x=1726645387; darn=lists.infradead.org; h=content-disposition:mime-version:message-id:subject:cc:to:from:date :from:to:cc:subject:date:message-id:reply-to; bh=As6Mh+lzj3Gz1WRcYQZrDI90Xpd0PmMaVKgj6FhuHj4=; b=xY/TZAZbQbUlGGUEMPvPVo/BMkatTnzdTFyHfECJspEDrJv8bCfhKsj01KjVToDptl uOi8jB8m0d1xPcNXUUZ+8wKpPrTDDwm724I3FCpKndRRxQSJgxvBCLCh67dylxBoZv7w /3iC7xacGYWkSTZszyleniCUiTkaVvMJDwU20R/RPH+QuTc1xXEM0TWaZkynCm1S29JC behzV8B52UM68TJhmkzXUNGlPMqKVguOw/e7cOrjSZM7VXlLTHtAHFpHTFCh8Rr1ilfa uMjQ49o/0snSumw17R3gPKwQps1eJUgkbPPYW8XqxSjKkyIKmxdICpMbWBFYDQBhRTpK XGpw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1726040587; x=1726645387; h=content-disposition:mime-version:message-id:subject:cc:to:from:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=As6Mh+lzj3Gz1WRcYQZrDI90Xpd0PmMaVKgj6FhuHj4=; b=iYBo+S9ZrNtK7OK3vRjC4NEX04Jz7p1ArXRRJbWGEkSyXFsWKbKfmxozJ2H2pgKAa9 3wNyXiYVPmXrqsX8H8zC5R3bTPjzB/uysidiNJKvlBj+XckdAvPn2DsLIDypbjfpTx0b 9wI3cVD8amdH7VXSRO3HZrA7/tUpEJ1bYzPVEjtK5ScATbxCI2X+uQqhv4289ICf+W7v L+msivu5BfO0bwF1qwUkIkLCKfiEyBe99m1WoCuQn6dsExELVVJ0Ze+ieZL6cZkEHnA4 vBcziL3E82Lc5wuRIUgkvWDRUz5dJoxGLo3xW8E1dQ7lib6/jZYniUCDe6eex5tqMMmc rr2w== X-Forwarded-Encrypted: i=1; AJvYcCXt2Kcc2Dt/U8mTxISnDNWDxl3yIeSkJZ9KYU4CIkBjMUi6D0ZAbz30Jsn/ptcnZlseLam+hWfoZwmDsU8xrma3@lists.infradead.org X-Gm-Message-State: AOJu0YyCUuVYQn2HEye9m3vWFvKpKm8L4/c0r1ml30/Jsi842MInSIhP b0yoD4kwC2lzPXugpOx/imonjy8jgDzKLykT2X/iWFyFc5DoxBg1DK0jCYI786U= X-Google-Smtp-Source: AGHT+IHOJBC9xWxtEz333I412PsRAnwCCXfRzkH+Q812eYtVEcfH3PlSFuvh4othUga0PEr6w0xhXg== X-Received: by 2002:adf:f4cc:0:b0:371:86bc:6c05 with SMTP id ffacd0b85a97d-378895c31ddmr9796759f8f.10.1726040586743; Wed, 11 Sep 2024 00:43:06 -0700 (PDT) Received: from localhost ([196.207.164.177]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-378956e8a98sm10786306f8f.117.2024.09.11.00.43.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 11 Sep 2024 00:43:06 -0700 (PDT) Date: Wed, 11 Sep 2024 10:43:03 +0300 From: Dan Carpenter To: Ming Yen Hsieh Cc: Felix Fietkau , Lorenzo Bianconi , Ryder Lee , Shayne Chen , Sean Wang , Kalle Valo , Matthias Brugger , AngeloGioacchino Del Regno , Deren Wu , linux-wireless@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org, kernel-janitors@vger.kernel.org Subject: [PATCH next] wifi: mt76: mt7925: fix off by one in mt7925_load_clc() Message-ID: <84bf5dd2-2fe3-4410-a7af-ae841e41082a@stanley.mountain> MIME-Version: 1.0 Content-Disposition: inline X-Mailer: git-send-email haha only kidding X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240911_004308_956778_E1A70694 X-CRM114-Status: GOOD ( 14.06 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org This comparison should be >= instead of > to prevent an out of bounds read and write. Fixes: 9679ca7326e5 ("wifi: mt76: mt7925: fix a potential array-index-out-of-bounds issue for clc") Signed-off-by: Dan Carpenter --- drivers/net/wireless/mediatek/mt76/mt7925/mcu.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/net/wireless/mediatek/mt76/mt7925/mcu.c b/drivers/net/wireless/mediatek/mt76/mt7925/mcu.c index 748ea6adbc6b..0c2a2337c313 100644 --- a/drivers/net/wireless/mediatek/mt76/mt7925/mcu.c +++ b/drivers/net/wireless/mediatek/mt76/mt7925/mcu.c @@ -638,7 +638,7 @@ static int mt7925_load_clc(struct mt792x_dev *dev, const char *fw_name) for (offset = 0; offset < len; offset += le32_to_cpu(clc->len)) { clc = (const struct mt7925_clc *)(clc_base + offset); - if (clc->idx > ARRAY_SIZE(phy->clc)) + if (clc->idx >= ARRAY_SIZE(phy->clc)) break; /* do not init buf again if chip reset triggered */