Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp3863626rwb; Sat, 3 Dec 2022 12:23:50 -0800 (PST) X-Google-Smtp-Source: AA0mqf4uIvTvzQJORaUleSgnKnlvDqb2sSzx0gw4/xxN5aUwCo7IbjdnwU/HikaeJ64Vd7PL2VRo X-Received: by 2002:a17:903:240a:b0:188:5d24:87e with SMTP id e10-20020a170903240a00b001885d24087emr58881316plo.87.1670099030378; Sat, 03 Dec 2022 12:23:50 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1670099030; cv=none; d=google.com; s=arc-20160816; b=nLuHtuhhx3/WhYefTk1alzCTog6l5LQQHkvcQyC9pE4BtczEsbsquXwFx+eWyjU3n5 gSZYg9r8QEjPvWFLS6y/BHSwvY3mRRyZug+DOMQxYKPUVXOWLDEW8YvzngagdXFEwOem 817OrxTKy3jQJtFhbwJRsVnvOEVhcdFOCyRGXenPhWFutkiYL1Ydh4MNQwz+jTY6BGW3 gDaw3Hbh5yLpNWk5rAsIBS6RDcU1fe48hTneCyDDTxP3YHiI1GNR0E5pnsXhjjF2Jqxq cULGKW+iVsu52r+R24AzHRGg3s/GhUasawApBDVJvUQyxsdr6HNM8bfl1IWeFbFxbjtk foPw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=Yt/yPwPuW3hAfnkfu7eCbMYq4Vk2iv+uMPNFflGJg0o=; b=PUO6sMddpXudndO6yQLOuwMOBtVHV4aZYH7VhXTIoOQrjUm3TihBY/L7F1jXmkjHFB m+Qjd2YhzcpJLeHdz5HKQcBv+LWdSQoT+HB9ytfxMn9UF09QAmnJQ36NCGfDGAfJwO8D Ydu5cShwaK8AngNoMM+W9wAI1xO5OkqFgAuNw+YOY87VcUt8m0ggPANcMlzAbIgCKvQX uRxsRywLWZzjEWwjYdV8OIR7gidQels17es4NHHEmkiBeYlaKKkeOzXS43HHHpIy6oG1 kxAOLlkS+QOvR4eUqukdBKnzBoEILWTEZf77veRqz4mN4H5R7ECaZqR/NtLrvNzp77YE +aDQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@mediatek.com header.s=dk header.b=o02GCb2p; 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 m2-20020a625802000000b0056262d97880si10050050pfb.186.2022.12.03.12.23.34; Sat, 03 Dec 2022 12:23:50 -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=o02GCb2p; 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 S229714AbiLCT3e (ORCPT + 66 others); Sat, 3 Dec 2022 14:29:34 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36302 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229615AbiLCT3d (ORCPT ); Sat, 3 Dec 2022 14:29:33 -0500 Received: from mailgw01.mediatek.com (unknown [60.244.123.138]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 27219192AA for ; Sat, 3 Dec 2022 11:29:26 -0800 (PST) X-UUID: 2b4c80ad791e4f5f830550f84a5eaa8f-20221204 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=mediatek.com; s=dk; h=Content-Type:MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:CC:To:From; bh=Yt/yPwPuW3hAfnkfu7eCbMYq4Vk2iv+uMPNFflGJg0o=; b=o02GCb2paAaA1PJKkfnZKcZpBMH2M4UizSGD9+v6S33oNM9nAbDea8lJaVHOjw4ZuYitfWrqhi31Ai3gNqz5ge5f5ByOJvvUJaxs0jmixcfPIcTBjkcKoDBtLsV7BjH4dGnoLzzVLdfZLnLT9Yp/430rmhd5+JQoFc9oeWIiQWA=; X-CID-P-RULE: Release_Ham X-CID-O-INFO: VERSION:1.1.14,REQID:6a975d0b-2a2f-4064-ac23-71518ba9dbbb,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:6a975d0b-2a2f-4064-ac23-71518ba9dbbb,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:fc2a766c-41fe-47b6-8eb4-ec192dedaf7d,B ulkID:221204032922R0NUAOW6,BulkQuantity:1,Recheck:0,SF:38|28|17|19|48,TC:n il,Content:0,EDM:-3,IP:nil,URL:0,File:nil,Bulk:43,QS:nil,BEC:nil,COL:0 X-UUID: 2b4c80ad791e4f5f830550f84a5eaa8f-20221204 Received: from mtkcas10.mediatek.inc [(172.21.101.39)] by mailgw01.mediatek.com (envelope-from ) (Generic MTA with TLSv1.2 ECDHE-RSA-AES256-SHA384 256/256) with ESMTP id 274066127; Sun, 04 Dec 2022 03:29:24 +0800 Received: from mtkmbs11n2.mediatek.inc (172.21.101.187) by mtkmbs10n2.mediatek.inc (172.21.101.183) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.792.3; Sun, 4 Dec 2022 03:29:23 +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:21 +0800 From: Ryder Lee To: Felix Fietkau , CC: Lorenzo Bianconi , Shayne Chen , Evelyn Tsai , , Ryder Lee Subject: [PATCH 2/3] wifi: mt76: mt7915: check return value before accessing free_block_num Date: Sun, 4 Dec 2022 03:29:18 +0800 Message-ID: X-Mailer: git-send-email 2.18.0 In-Reply-To: References: 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, T_SPF_TEMPERROR,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 mt7915_mcu_get_eeprom_free_block() first before accessing free_block_num. Fixes: bbc1d4154ec1 ("mt76: mt7915: add default calibrated data support") Signed-off-by: Ryder Lee --- drivers/net/wireless/mediatek/mt76/mt7915/eeprom.c | 7 +++++-- drivers/net/wireless/mediatek/mt76/mt7915/mcu.c | 4 ++-- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/drivers/net/wireless/mediatek/mt76/mt7915/eeprom.c b/drivers/net/wireless/mediatek/mt76/mt7915/eeprom.c index 59069fb86414..3ab07ad0c26e 100644 --- a/drivers/net/wireless/mediatek/mt76/mt7915/eeprom.c +++ b/drivers/net/wireless/mediatek/mt76/mt7915/eeprom.c @@ -111,8 +111,11 @@ static int mt7915_eeprom_load(struct mt7915_dev *dev) u8 free_block_num; u32 block_num, i; - mt7915_mcu_get_eeprom_free_block(dev, &free_block_num); - /* efuse info not enough */ + ret = mt7915_mcu_get_eeprom_free_block(dev, &free_block_num); + if (ret < 0) + return ret; + + /* efuse info isn't enough */ if (free_block_num >= 29) return -EINVAL; diff --git a/drivers/net/wireless/mediatek/mt76/mt7915/mcu.c b/drivers/net/wireless/mediatek/mt76/mt7915/mcu.c index ca315af3905b..f9e4c3e80af0 100644 --- a/drivers/net/wireless/mediatek/mt76/mt7915/mcu.c +++ b/drivers/net/wireless/mediatek/mt76/mt7915/mcu.c @@ -2792,8 +2792,8 @@ int mt7915_mcu_get_eeprom(struct mt7915_dev *dev, u32 offset) int ret; u8 *buf; - ret = mt76_mcu_send_and_get_msg(&dev->mt76, MCU_EXT_QUERY(EFUSE_ACCESS), &req, - sizeof(req), true, &skb); + ret = mt76_mcu_send_and_get_msg(&dev->mt76, MCU_EXT_QUERY(EFUSE_ACCESS), + &req, sizeof(req), true, &skb); if (ret) return ret; -- 2.18.0