Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp3834814rwb; Sat, 3 Dec 2022 11:48:24 -0800 (PST) X-Google-Smtp-Source: AA0mqf6/Iuir/isbOxR5vnXyVsf0yLvyV/z0nzBQPb5P+6iO/qqbxedpyRKHN2sKDN27pyn3lJTj X-Received: by 2002:a17:90a:1c96:b0:219:4ae8:1d9b with SMTP id t22-20020a17090a1c9600b002194ae81d9bmr27418721pjt.147.1670096904539; Sat, 03 Dec 2022 11:48:24 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1670096904; cv=none; d=google.com; s=arc-20160816; b=LPm23o4OqRMLBjaDX14+DyPLzDAWgsE0sExBCX97n4vomoOkq+PekQoa7iCelBk+cR 3IUKKxQKTiBvTDKv8VIr/bOC9yrlYIy0vFBByUOwKmHAWAFC8LBSOS4MmFsE8vo8q/FR FGM3QdNbMHi68h5y4ntK7dgiQUg8KSfpR0PPx5VklppljWNNjEOSESesH+txs7VrZ+OD tkBqO62UTH37gYWIEocZD5zq+0urHCQg0uVqg/LeDIWFxlBXdcJT7e2Cw1BtxLOciT2k tQyUbm4+3gRhfb5Evvzb5E2/vVHuSUsSIZuhkmI3ybKbAR2aGlM0I5i9xU8iFNwrr6YS wb1A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:message-id:date:subject:cc:to:from :dkim-signature; bh=o+e5JgFVSzaFAhjErXARpJtvL274Xm1EIt7wWw/9bjQ=; b=Z1Hjv6hQxyOXECG9IN7o/YByKx07sUXjlo+P6jB/ZiaWLdpkTmxYgT1qDyAIRyknBp KgImSn3R2XpfhqMMLA2IMs9VY07nLRB6PcBQ+AJ7hZ/3+368caT4nZmpGhNvPIcVdFyA 58AVyq5s7e4762VhtjBcO1ZKyVO+s2KPzDm0aTRMu4mqNizwbOiB5UabmqvyOlackVRO z8rJ505iJ1UkJ0OKHxYzXqRTNGe2TVYjYm0zCzjuZYYz4OnE83wb7HDYk4uYVZZWdhFa SEOAafwewWTr2KuG9ZEroCg7nQwAFkFrIDAI1BZjGoeM7xGmDix3yQsFMRZDTNNo8adD SLBw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@mediatek.com header.s=dk header.b=iB0OjpiR; spf=pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-wireless-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=mediatek.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id c7-20020a056a000ac700b0056bf15d0cbfsi11532076pfl.308.2022.12.03.11.48.09; Sat, 03 Dec 2022 11:48:24 -0800 (PST) Received-SPF: pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@mediatek.com header.s=dk header.b=iB0OjpiR; spf=pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-wireless-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=mediatek.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229795AbiLCT3h (ORCPT + 66 others); Sat, 3 Dec 2022 14:29:37 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36314 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229602AbiLCT3g (ORCPT ); Sat, 3 Dec 2022 14:29:36 -0500 Received: from mailgw02.mediatek.com (unknown [210.61.82.184]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CE08D1B7A7 for ; Sat, 3 Dec 2022 11:29:27 -0800 (PST) X-UUID: df371658c52f430db8ca6f1c9823a5c9-20221204 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=mediatek.com; s=dk; h=Content-Type:MIME-Version:Message-ID:Date:Subject:CC:To:From; bh=o+e5JgFVSzaFAhjErXARpJtvL274Xm1EIt7wWw/9bjQ=; b=iB0OjpiRrEzt+9Hq6FFRoNZlzhF1FgvsyTQwQjgM3WkXEOGBVpNv6zws+6RX5SDA1ZWQD5ccDu3jdVxOr9+kz7gouxPJ8rh5AQUsiIYjvi0pyu7tZHHXmOZ/c7rEaiFGVBTRjJd4njnzWDvPN8h3MdY8gzIlD14X4H+fXbi/0Vc=; X-CID-P-RULE: Release_Ham X-CID-O-INFO: VERSION:1.1.14,REQID:f4235d4f-758c-4ade-8824-283c4d6598ef,IP:0,U RL:0,TC:0,Content:-5,EDM:0,RT:0,SF:95,FILE:0,BULK:0,RULE:Release_Ham,ACTIO N:release,TS:90 X-CID-INFO: VERSION:1.1.14,REQID:f4235d4f-758c-4ade-8824-283c4d6598ef,IP:0,URL :0,TC:0,Content:-5,EDM:0,RT:0,SF:95,FILE:0,BULK:0,RULE:Spam_GS981B3D,ACTIO N:quarantine,TS:90 X-CID-META: VersionHash:dcaaed0,CLOUDID:16479330-2938-482e-aafd-98d66723b8a9,B ulkID:221204032922R0NUAOW6,BulkQuantity:0,Recheck:0,SF:38|28|17|19|48,TC:n il,Content:0,EDM:-3,IP:nil,URL:0,File:nil,Bulk:nil,QS:nil,BEC:nil,COL:0 X-UUID: df371658c52f430db8ca6f1c9823a5c9-20221204 Received: from mtkcas10.mediatek.inc [(172.21.101.39)] by mailgw02.mediatek.com (envelope-from ) (Generic MTA with TLSv1.2 ECDHE-RSA-AES256-SHA384 256/256) with ESMTP id 1280511545; Sun, 04 Dec 2022 03:29:21 +0800 Received: from mtkmbs11n2.mediatek.inc (172.21.101.187) by mtkmbs13n2.mediatek.inc (172.21.101.108) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.792.15; Sun, 4 Dec 2022 03:29:20 +0800 Received: from mtksdccf07.mediatek.inc (172.21.84.99) by mtkmbs11n2.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.2.792.15 via Frontend Transport; Sun, 4 Dec 2022 03:29:20 +0800 From: Ryder Lee To: Felix Fietkau , CC: Lorenzo Bianconi , Shayne Chen , Evelyn Tsai , , Ryder Lee Subject: [PATCH 1/3] wifi: mt76: mt7996: check return value before accessing free_block_num Date: Sun, 4 Dec 2022 03:29:17 +0800 Message-ID: X-Mailer: git-send-email 2.18.0 MIME-Version: 1.0 Content-Type: text/plain X-MTK: N X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_MSPIKE_H2,SPF_HELO_PASS, SPF_PASS,UNPARSEABLE_RELAY autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org Check return value of mt7996_mcu_get_eeprom_free_block() first before accessing free_block_num. Fixes: 98686cd21624 ("wifi: mt76: mt7996: add driver for MediaTek Wi-Fi 7 (802.11be) devices") Signed-off-by: Ryder Lee --- drivers/net/wireless/mediatek/mt76/mt7996/eeprom.c | 8 +++++--- drivers/net/wireless/mediatek/mt76/mt7996/mcu.c | 4 ++-- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/drivers/net/wireless/mediatek/mt76/mt7996/eeprom.c b/drivers/net/wireless/mediatek/mt76/mt7996/eeprom.c index b9f62bedbc48..b61d12dafc9f 100644 --- a/drivers/net/wireless/mediatek/mt76/mt7996/eeprom.c +++ b/drivers/net/wireless/mediatek/mt76/mt7996/eeprom.c @@ -66,9 +66,11 @@ static int mt7996_eeprom_load(struct mt7996_dev *dev) u8 free_block_num; u32 block_num, i; - /* TODO: check free block event */ - mt7996_mcu_get_eeprom_free_block(dev, &free_block_num); - /* efuse info not enough */ + ret = mt7996_mcu_get_eeprom_free_block(dev, &free_block_num); + if (ret < 0) + return ret; + + /* efuse info isn't enough */ if (free_block_num >= 59) return -EINVAL; diff --git a/drivers/net/wireless/mediatek/mt76/mt7996/mcu.c b/drivers/net/wireless/mediatek/mt76/mt7996/mcu.c index efb245c8ac84..e4ec395426a7 100644 --- a/drivers/net/wireless/mediatek/mt76/mt7996/mcu.c +++ b/drivers/net/wireless/mediatek/mt76/mt7996/mcu.c @@ -2927,8 +2927,8 @@ int mt7996_mcu_get_eeprom(struct mt7996_dev *dev, u32 offset) bool valid; int ret; - ret = mt76_mcu_send_and_get_msg(&dev->mt76, MCU_WM_UNI_CMD_QUERY(EFUSE_CTRL), &req, - sizeof(req), true, &skb); + ret = mt76_mcu_send_and_get_msg(&dev->mt76, MCU_WM_UNI_CMD_QUERY(EFUSE_CTRL), + &req, sizeof(req), true, &skb); if (ret) return ret; -- 2.18.0