Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp2468467imm; Thu, 7 Jun 2018 11:05:33 -0700 (PDT) X-Google-Smtp-Source: ADUXVKKUdynXyem5UrJUYhZAUxvCv8u8zAjAl/IXCEXlSOelPgEfrWz1ygiRIVSKFGf+mKTAQw+o X-Received: by 2002:a62:b201:: with SMTP id x1-v6mr2720111pfe.189.1528394733549; Thu, 07 Jun 2018 11:05:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528394733; cv=none; d=google.com; s=arc-20160816; b=XblCsO5aaRp4kfePzzLbwgnCuKs1E5flqR4ClEZs2CDgxzxpgAuBFxTxC1EkTCMWBi uheLnTYgabGIj7BF9gmqlzuey1BXqccOHcGtTBHS9EsDc7nzmwrSNjE+u6WYCHP/8ceW n5wDAYuQgVBlGfDs45bRHnRlrABedTUJDXIi7RzSRVmtlTQj+3WJn4UsgJc3CUhM6eqR faiS7z2sYss7Gyx/8QQuDI+B4HYcFIx2vkXH8BHIjBmHd39/WUzbV49SoiAq3/GMZ23H ZFEbWV9CUwWGh/XqHGnLKfeFGGKdmZyPMw9jYw3WR3njF0lSJNMMMsWmF6JOuPPU3xsg d2qw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:subject:message-id:date:cc:to :from:mime-version:content-transfer-encoding:content-disposition :arc-authentication-results; bh=PI3x0r/KlRrMtxMNeBCsR5zD3dD3qmmVNThNUJOpKJU=; b=b63T0wl53bppAY/qaceb8pUauwlin8fiNrHzaRZZhVBI/qbSfAEBBEpZxmS4Jl0mqY X/Xy6Ebjv92yMx6ybx8mkDgNn+wDv115zhfi9BRK9QPuKaGKcqjJYqCwJDHYQiJGIpNO 2aqlpaQIOwEWLfhqEbFpVDoFIBqo+9MmoRc3Zy2AsxBWuTZjAALZR00iSDfbWCrzN/+g DKKCtql1pVuhzexQ3epPtp4RKbigGh+iBrV5fPXAuYn6uNNKSKNiZH7wM6qua0ztj80Q 8rzZirj8C2i55m3sbeYANU4LAcySsknIglz4NYxcq0x0eWiFYYz9ai6qntuR/sItstu3 SKfA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id j77-v6si14405808pfa.57.2018.06.07.11.05.19; Thu, 07 Jun 2018 11:05:33 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S935556AbeFGO6s (ORCPT + 99 others); Thu, 7 Jun 2018 10:58:48 -0400 Received: from shadbolt.e.decadent.org.uk ([88.96.1.126]:41206 "EHLO shadbolt.e.decadent.org.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S935544AbeFGO6l (ORCPT ); Thu, 7 Jun 2018 10:58:41 -0400 Received: from [148.252.241.226] (helo=deadeye) by shadbolt.decadent.org.uk with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1fQvbT-0005Zl-LJ; Thu, 07 Jun 2018 15:09:28 +0100 Received: from ben by deadeye with local (Exim 4.91) (envelope-from ) id 1fQvbB-0003Bw-QO; Thu, 07 Jun 2018 15:09:09 +0100 Content-Type: text/plain; charset="UTF-8" Content-Disposition: inline Content-Transfer-Encoding: 8bit MIME-Version: 1.0 From: Ben Hutchings To: linux-kernel@vger.kernel.org, stable@vger.kernel.org CC: akpm@linux-foundation.org, "Hans de Goede" , "Hante Meuleman" , "Arend Van Spriel" , "Franky Lin" , "Kalle Valo" , "Pieter-Paul Giesberts" Date: Thu, 07 Jun 2018 15:05:21 +0100 Message-ID: X-Mailer: LinuxStableQueue (scripts by bwh) Subject: [PATCH 3.16 328/410] brcmfmac: fix P2P_DEVICE ethernet address generation In-Reply-To: X-SA-Exim-Connect-IP: 148.252.241.226 X-SA-Exim-Mail-From: ben@decadent.org.uk X-SA-Exim-Scanned: No (on shadbolt.decadent.org.uk); SAEximRunCond expanded to false Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 3.16.57-rc1 review patch. If anyone has any objections, please let me know. ------------------ From: Arend Van Spriel commit 455f3e76cfc0d893585a5f358b9ddbe9c1e1e53b upstream. The firmware has a requirement that the P2P_DEVICE address should be different from the address of the primary interface. When not specified by user-space, the driver generates the MAC address for the P2P_DEVICE interface using the MAC address of the primary interface and setting the locally administered bit. However, the MAC address of the primary interface may already have that bit set causing the creation of the P2P_DEVICE interface to fail with -EBUSY. Fix this by using a random address instead to determine the P2P_DEVICE address. Reported-by: Hans de Goede Reviewed-by: Hante Meuleman Reviewed-by: Pieter-Paul Giesberts Reviewed-by: Franky Lin Signed-off-by: Arend van Spriel Signed-off-by: Kalle Valo [bwh: Backported to 3.16: adjust filename] Signed-off-by: Ben Hutchings --- drivers/net/wireless/brcm80211/brcmfmac/p2p.c | 24 +++++++++---------- 1 file changed, 11 insertions(+), 13 deletions(-) --- a/drivers/net/wireless/brcm80211/brcmfmac/p2p.c +++ b/drivers/net/wireless/brcm80211/brcmfmac/p2p.c @@ -457,25 +457,23 @@ static int brcmf_p2p_set_firmware(struct * @dev_addr: optional device address. * * P2P needs mac addresses for P2P device and interface. If no device - * address it specified, these are derived from the primary net device, ie. - * the permanent ethernet address of the device. + * address it specified, these are derived from a random ethernet + * address. */ static void brcmf_p2p_generate_bss_mac(struct brcmf_p2p_info *p2p, u8 *dev_addr) { - struct brcmf_if *pri_ifp = p2p->bss_idx[P2PAPI_BSSCFG_PRIMARY].vif->ifp; - bool local_admin = false; + bool random_addr = false; - if (!dev_addr || is_zero_ether_addr(dev_addr)) { - dev_addr = pri_ifp->mac_addr; - local_admin = true; - } + if (!dev_addr || is_zero_ether_addr(dev_addr)) + random_addr = true; - /* Generate the P2P Device Address. This consists of the device's - * primary MAC address with the locally administered bit set. + /* Generate the P2P Device Address obtaining a random ethernet + * address with the locally administered bit set. */ - memcpy(p2p->dev_addr, dev_addr, ETH_ALEN); - if (local_admin) - p2p->dev_addr[0] |= 0x02; + if (random_addr) + eth_random_addr(p2p->dev_addr); + else + memcpy(p2p->dev_addr, dev_addr, ETH_ALEN); /* Generate the P2P Interface Address. If the discovery and connection * BSSCFGs need to simultaneously co-exist, then this address must be