From patchwork Tue Jan 26 16:57:01 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?b?UmFmYcWCIE1pxYJlY2tp?= X-Patchwork-Id: 8124821 X-Patchwork-Delegate: kvalo@adurom.com Return-Path: X-Original-To: patchwork-linux-wireless@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 02C139F6DA for ; Tue, 26 Jan 2016 16:57:30 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 0C1E22026D for ; Tue, 26 Jan 2016 16:57:29 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 33A6320266 for ; Tue, 26 Jan 2016 16:57:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S966843AbcAZQ50 (ORCPT ); Tue, 26 Jan 2016 11:57:26 -0500 Received: from mail-lf0-f54.google.com ([209.85.215.54]:34620 "EHLO mail-lf0-f54.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S966826AbcAZQ5W (ORCPT ); Tue, 26 Jan 2016 11:57:22 -0500 Received: by mail-lf0-f54.google.com with SMTP id 17so109170182lfz.1 for ; Tue, 26 Jan 2016 08:57:21 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-type:content-transfer-encoding; bh=AvhswAg7XWwKyNf5NZdF0knScMztbNygVs6CuJqSHjU=; b=Iz4H7m1VDiOtGuo1tZ3QCwjTqEE7+MOcbHIbSvaZQUG8r05NwkkOuwNSkr5MUeVcG0 01v/WoS4rAiVL1gw7x5Izl1z6qlRNpOvbi+Vr1rTO6e4ZT/76Ewhq6jf9d4MRln8Hz5j yBxd6NoJAHMgzVbrMnUj1wA+gBN72w6sFWjoQOIgwQ2+TdH1m9/C3tynpCi0FvU2N7AS tsu359dO4cS5gu/Hm/OSUT85FC71PW8TRmJeVhUsQyUPSRo1APCOG1NdKQTUdgHo/Jkl nRSNnyKjnDK+GaokQqMr9uxJ8Blxr0hPM6jb2fokDSlWDNB5GmWs8dzVE+deij91j1WT v8Qw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-type:content-transfer-encoding; bh=AvhswAg7XWwKyNf5NZdF0knScMztbNygVs6CuJqSHjU=; b=QdhqD+MsluC3ia6RO6mnDNM3N9ZhFSoR9mnecAgr/9M0i+DHHWhsVeBp/VvbRy8NGO bzZ5WZBRJ4zSAFai77rt8SglnNqp6fnjapGTz9FA13ZgaumBoQUYDwflKISN0hFTCldf uiv2I/HKbYno+M28/1euJv9UV5Gj6+sLSb1qMmDHWEH/g26rVFtMcDgr7c92ROpv3nmL kEyHHA4AzLgTc3KKVcc0vOIH1mRB8qYPq5BId5HmcqvR03QuwFGVHe+xFuWyDSPR6IWy 7kyqmPqf2CPHRsBR/7Fd09U3d28uyde/9KkNh2+64rQyFlUEVpLE2NBxARz0nKD9nep/ 97Ug== X-Gm-Message-State: AG10YOShlrayQ3Y/XmBD1+GjVrGQxlMK5/vX5+ezdgtFrrPoP/tN+aKiTN80sE41JsCIuA== X-Received: by 10.25.18.162 with SMTP id 34mr7907476lfs.52.1453827440623; Tue, 26 Jan 2016 08:57:20 -0800 (PST) Received: from linux-samsung.lan (ip-194-187-74-233.konfederacka.maverick.com.pl. [194.187.74.233]) by smtp.gmail.com with ESMTPSA id h187sm292998lfg.18.2016.01.26.08.57.18 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 26 Jan 2016 08:57:19 -0800 (PST) From: =?UTF-8?q?Rafa=C5=82=20Mi=C5=82ecki?= To: Kalle Valo , linux-wireless@vger.kernel.org Cc: Brett Rudley , Arend van Spriel , "Franky (Zhenhui) Lin" , Hante Meuleman , brcm80211-dev-list@broadcom.com, =?UTF-8?q?Rafa=C5=82=20Mi=C5=82ecki?= Subject: [PATCH 1/5] brcmfmac: analyze descriptors of current component only Date: Tue, 26 Jan 2016 17:57:01 +0100 Message-Id: <1453827425-16455-2-git-send-email-zajec5@gmail.com> X-Mailer: git-send-email 1.8.4.5 In-Reply-To: <1453827425-16455-1-git-send-email-zajec5@gmail.com> References: <1453827425-16455-1-git-send-email-zajec5@gmail.com> MIME-Version: 1.0 Sender: linux-wireless-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org X-Spam-Status: No, score=-6.8 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP So far we were looking for address descriptors without a check for crossing current component border. In case of dealing with unsupported descriptor or descriptor missing at all the code would incorrectly get data from another component. Consider this binary-described component from BCM4366 EROM: 4bf83b01 TAG==CI CID==0x83b 20080201 TAG==CI PORTS==0+1 WRAPPERS==0+1 18400035 TAG==ADDR SZ_SZD TYPE_SLAVE 00050000 18107085 TAG==ADDR SZ_4K TYPE_SWRAP Driver was assigning invalid base address to this core: brcmfmac: [6 ] core 0x83b:32 base 0x18109000 wrap 0x18107000 which came from totally different component defined in EROM: 43b36701 TAG==CI CID==0x367 00000201 TAG==CI PORTS==0+1 WRAPPERS==0+0 18109005 TAG==ADDR SZ_4K TYPE_SLAVE This change will also allow us to support components without wrapper address in the future. Signed-off-by: Rafa? Mi?ecki --- drivers/net/wireless/broadcom/brcm80211/brcmfmac/chip.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/chip.c b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/chip.c index 82e4382..e434e2a 100644 --- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/chip.c +++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/chip.c @@ -803,7 +803,14 @@ static int brcmf_chip_dmp_get_regaddr(struct brcmf_chip_priv *ci, u32 *eromaddr, *eromaddr -= 4; return -EFAULT; } - } while (desc != DMP_DESC_ADDRESS); + } while (desc != DMP_DESC_ADDRESS && + desc != DMP_DESC_COMPONENT); + + /* stop if we crossed current component border */ + if (desc == DMP_DESC_COMPONENT) { + *eromaddr -= 4; + return 0; + } /* skip upper 32-bit address descriptor */ if (val & DMP_DESC_ADDRSIZE_GT32)