From patchwork Fri Sep 7 17:21:57 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Brian Norris X-Patchwork-Id: 10592411 X-Patchwork-Delegate: kvalo@adurom.com Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 1F96E6CB for ; Fri, 7 Sep 2018 17:23:51 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 05DEA2AF46 for ; Fri, 7 Sep 2018 17:23:51 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id ED9602B2BA; Fri, 7 Sep 2018 17:23:50 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 996A82AF46 for ; Fri, 7 Sep 2018 17:23:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727662AbeIGWFk (ORCPT ); Fri, 7 Sep 2018 18:05:40 -0400 Received: from mail-pl1-f194.google.com ([209.85.214.194]:42731 "EHLO mail-pl1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727645AbeIGWFj (ORCPT ); Fri, 7 Sep 2018 18:05:39 -0400 Received: by mail-pl1-f194.google.com with SMTP id g23-v6so6872084plq.9 for ; Fri, 07 Sep 2018 10:23:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=F3EScKHq882HmXSXacc/H2P5d85KqjVc6VQWxTmcaqM=; b=XjIKEMq7MJDedGI6KTXvY7jaA/GtXddn+4QP/k1WPKX1eZb2QwTmV1pjiJPnB2WrqK oibPp4bXq5H0UFsStXyv2yPSzmYkRJ3UNeA9sEatS0/dzCKZRHJzaiQUvDt+1ddZKtkx eKUUWVZ6mKfI89iEWovb8Cr05qqKZmnN3PZ5k= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=F3EScKHq882HmXSXacc/H2P5d85KqjVc6VQWxTmcaqM=; b=CPd30NOwypgX+kBtH4uEJcANPUZF8Kymx66FJMwub4bzEolo2iPTrnzpq2UNbrOifj TIgYjTzis4mIcEAYAh6nahZke0fp4I2Bf8Q6Uxg9yLo2DO1/L4J4ajXKm3vY1x5kHBxw f8aRG/eCEJRDWm+um2Ui/Bo3ao7VIhS51U1O5sO7eogK8O6/8y7poJdHQf+FGeMw3qY9 UE3vEqtOl27RHHAYOVtF56MDIT443IW+gtqn00TO/+5urGOxA6bG5qSCJ71BjDSWfnYb q8X/md1mFHOEKj4+Mi6JCl5Nsm5o//M8Uv5w02KHTKhxULKk575qauJy+VsYooE+Kc11 3NVg== X-Gm-Message-State: APzg51AOZ1yHvPc0Nnn3S4M6OV3B+00uczmSh5I1FaKSbSgQsuMFAM0g m1735srApVuaxmVPdRorzuFSbA== X-Google-Smtp-Source: ANB0VdZP80c28VlbBiynmCZZj//n0X2AwAdo8Ayt1i1Z49+laNR/37RK7uIGFzbqb9nww+nI/4etew== X-Received: by 2002:a17:902:8e86:: with SMTP id bg6-v6mr9117767plb.108.1536341024871; Fri, 07 Sep 2018 10:23:44 -0700 (PDT) Received: from smtp.gmail.com ([2620:15c:202:1:299d:6b87:5478:d28a]) by smtp.gmail.com with ESMTPSA id q80-v6sm12908629pfd.15.2018.09.07.10.23.43 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 07 Sep 2018 10:23:43 -0700 (PDT) From: Brian Norris To: Kalle Valo Cc: ath10k@lists.infradead.org, linux-wireless@vger.kernel.org, Govind Singh , , Brian Norris Subject: [PATCH] ath10k: utilize random MAC address if none is provided Date: Fri, 7 Sep 2018 10:21:57 -0700 Message-Id: <20180907172157.203785-1-briannorris@chromium.org> X-Mailer: git-send-email 2.19.0.rc2.392.g5ba43deb5a-goog MIME-Version: 1.0 Sender: linux-wireless-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Since commit 9d5804662ce1 ("ath10k: retrieve MAC address from system firmware if provided"), we support pulling our MAC address from system firmware. Along with this, we should admit that it's possible for system firmware to be screwed up as well, omitting the MAC address there. Provide a fallback, such that we choose a randomly-generated MAC address, with the local assignment bit set. This is not a preferred mode of operation and really should only serve the purpose of keeping the system chugging along while someone figures out what's wrong with the system. Grepping through other wireless drivers shows very similar fallback logic though, so why not? git grep eth_random_addr drivers/net/wireless/ Signed-off-by: Brian Norris --- drivers/net/wireless/ath/ath10k/mac.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drivers/net/wireless/ath/ath10k/mac.c b/drivers/net/wireless/ath/ath10k/mac.c index 97548f96a2f7..484f9c74ce46 100644 --- a/drivers/net/wireless/ath/ath10k/mac.c +++ b/drivers/net/wireless/ath/ath10k/mac.c @@ -8325,6 +8325,10 @@ int ath10k_mac_register(struct ath10k *ar) void *channels; int ret; + if (!is_valid_ether_addr(ar->mac_addr)) { + ath10k_warn(ar, "invalid MAC address; choosing random\n"); + eth_random_addr(ar->mac_addr); + } SET_IEEE80211_PERM_ADDR(ar->hw, ar->mac_addr); SET_IEEE80211_DEV(ar->hw, ar->dev);