From patchwork Tue Nov 26 13:15:54 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shayne Chen X-Patchwork-Id: 11262343 X-Patchwork-Delegate: nbd@nbd.name Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id ED62713A4 for ; Tue, 26 Nov 2019 13:17:48 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id CE42F20862 for ; Tue, 26 Nov 2019 13:17:48 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=mediatek.com header.i=@mediatek.com header.b="kA3On3Uq" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728087AbfKZNRs (ORCPT ); Tue, 26 Nov 2019 08:17:48 -0500 Received: from mailgw01.mediatek.com ([210.61.82.183]:10995 "EHLO mailgw01.mediatek.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1727734AbfKZNRr (ORCPT ); Tue, 26 Nov 2019 08:17:47 -0500 X-UUID: d280355e739a48b6bb8f3d13768babdb-20191126 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=mediatek.com; s=dk; h=Content-Transfer-Encoding:Content-Type:MIME-Version:Message-ID:Date:Subject:CC:To:From; bh=jZRVn5TlvJrTrTr3DZJgx1M6iBQCf9Nk3/ncmMlFv4c=; b=kA3On3UqMr2kt4qal2yIT1KEbiJV03Qro/4TAmEi6iPnTLx1dCxa/VKUzpGz8T8aSJd2ZqZNp6UV3J9859hEdidqJYz92Ffdy0PcBhZE6seCTZ7TEQDKuUaAR6tf55jQ/bVrdi9SDxNO+1jqlUVVoloob6RVgMG9S5/pUILMvWU=; X-UUID: d280355e739a48b6bb8f3d13768babdb-20191126 Received: from mtkcas08.mediatek.inc [(172.21.101.126)] by mailgw01.mediatek.com (envelope-from ) (Cellopoint E-mail Firewall v4.1.10 Build 0809 with TLS) with ESMTP id 295749486; Tue, 26 Nov 2019 21:17:42 +0800 Received: from MTKCAS06.mediatek.inc (172.21.101.30) by mtkmbs06n2.mediatek.inc (172.21.101.130) with Microsoft SMTP Server (TLS) id 15.0.1395.4; Tue, 26 Nov 2019 21:17:39 +0800 Received: from mtksdccf07.mediatek.inc (172.21.84.99) by MTKCAS06.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.0.1395.4 via Frontend Transport; Tue, 26 Nov 2019 21:17:36 +0800 From: Shayne Chen To: Felix Fietkau CC: linux-wireless , Lorenzo Bianconi , Lorenzo Bianconi , Ryder Lee , Roy Luo , linux-mediatek , Shayne Chen Subject: [PATCH] mt76: fix possible undetected invalid MAC address Date: Tue, 26 Nov 2019 21:15:54 +0800 Message-ID: <20191126131554.32457-1-shayne.chen@mediatek.com> X-Mailer: git-send-email 2.18.0 MIME-Version: 1.0 X-TM-SNTS-SMTP: C5DD055B51CD7A390C073BA74141EDA9DD3D1017221B87A0542E61E140A4008C2000:8 X-MTK: N Sender: linux-wireless-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org Make sure the MAC address is checked before function returns. If CONFIG_OF is set and the device node is null, the function will return directly, and an invalid MAC address will not be checked. Signed-off-by: Shayne Chen --- drivers/net/wireless/mediatek/mt76/eeprom.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/net/wireless/mediatek/mt76/eeprom.c b/drivers/net/wireless/mediatek/mt76/eeprom.c index 804224e81103..358fb0a1e523 100644 --- a/drivers/net/wireless/mediatek/mt76/eeprom.c +++ b/drivers/net/wireless/mediatek/mt76/eeprom.c @@ -80,13 +80,14 @@ mt76_eeprom_override(struct mt76_dev *dev) const u8 *mac; if (!np) - return; + goto out; mac = of_get_mac_address(np); if (!IS_ERR(mac)) ether_addr_copy(dev->macaddr, mac); #endif +out: if (!is_valid_ether_addr(dev->macaddr)) { eth_random_addr(dev->macaddr); dev_info(dev->dev,