From patchwork Sat May 23 07:15:33 2015 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: 6470361 X-Patchwork-Delegate: kvalo@adurom.com Return-Path: X-Original-To: patchwork-linux-wireless@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id A1F22C0020 for ; Sat, 23 May 2015 07:16:01 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id B1C79205D3 for ; Sat, 23 May 2015 07:15:57 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id AA7A6205D1 for ; Sat, 23 May 2015 07:15:53 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757522AbbEWHPv (ORCPT ); Sat, 23 May 2015 03:15:51 -0400 Received: from mail-wi0-f172.google.com ([209.85.212.172]:38863 "EHLO mail-wi0-f172.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756765AbbEWHPv (ORCPT ); Sat, 23 May 2015 03:15:51 -0400 Received: by wichy4 with SMTP id hy4so7138037wic.1 for ; Sat, 23 May 2015 00:15:50 -0700 (PDT) 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=x5hRyq7NdMeHVHGb81vwUMzwBeovT6YgwfnmVz8Wruk=; b=jAb7KrFWiJpCT8RTKzVdwzkkLaBetjQbuZkajsd7YNtfKXMW8HoE3zeqhUU9VyZrS8 LxS6Z7CVnn9i/L3tID4mBT5yOkWT8L9py7DvuvjSsG2sdNEjXEbWkHWgqxcFisTAWlNE y5ACvw+40MrS3fdkB+LDJ5zDcIt6jYA9mg7La7dlmqbi/mAY2EV7UkEPN6B/EXY5Wk9O PouDMf4BzsnfyIKdDR1f4w7ovBVcHqsmsjPW/ywzGP3hh5Nxh2m4qfxP74c/rMdKYjM4 CvKjr7q4CmLmjeh0ObmJxtf963k/sIe9+GI017FvtPVoPLVFkFihzmtXtHbAqDGT5oll VAzg== X-Received: by 10.194.63.80 with SMTP id e16mr22070375wjs.56.1432365349966; Sat, 23 May 2015 00:15:49 -0700 (PDT) Received: from linux-tdhb.lan (ip-194-187-74-233.konfederacka.maverick.com.pl. [194.187.74.233]) by mx.google.com with ESMTPSA id yz3sm6539399wjc.19.2015.05.23.00.15.47 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 23 May 2015 00:15:47 -0700 (PDT) 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 V4] brcmfmac: allow NVRAM values to contain spaces Date: Sat, 23 May 2015 09:15:33 +0200 Message-Id: <1432365333-1074-1-git-send-email-zajec5@gmail.com> X-Mailer: git-send-email 1.8.4.5 In-Reply-To: <1432331128-24011-1-git-send-email-zajec5@gmail.com> References: <1432331128-24011-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, T_DKIM_INVALID, T_RP_MATCHES_RCVD, 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 Platform NVRAMs often contain values with spaces. Even if right now most firmware-supported entries are simple values, we shouldn't reject these with spaces. It was semi-confirmed by Broadcom in the early patch adding support for platform NVRAMs. Signed-off-by: Rafa? Mi?ecki Acked-by: Arend van Spriel --- V2: Minor change in commit message only. Provide an example of NVRAM entry using space (not just a '#'). It's unprefixed (shouldn't be uploaded to hardware anyway), but proves it's allowed in general. V3: As commented by Arend, accept space only (not a '#'). V4: Fix typo in "Broadcom" in commit message --- drivers/net/wireless/brcm80211/brcmfmac/firmware.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/drivers/net/wireless/brcm80211/brcmfmac/firmware.c b/drivers/net/wireless/brcm80211/brcmfmac/firmware.c index 45d7191..baad939 100644 --- a/drivers/net/wireless/brcm80211/brcmfmac/firmware.c +++ b/drivers/net/wireless/brcm80211/brcmfmac/firmware.c @@ -66,6 +66,12 @@ struct nvram_parser { bool multi_dev_v2; }; +/** + * is_nvram_char() - check if char is a valid one for NVRAM entry + * + * It accepts all printable ASCII chars except for '#' which opens a comment. + * Please note that ' ' (space) while accepted is not a valid key name char. + */ static bool is_nvram_char(char c) { /* comment marker excluded */ @@ -73,7 +79,7 @@ static bool is_nvram_char(char c) return false; /* key and value may have any other readable character */ - return (c > 0x20 && c < 0x7f); + return (c >= 0x20 && c < 0x7f); } static bool is_whitespace(char c) @@ -120,7 +126,7 @@ static enum nvram_parser_state brcmf_nvram_handle_key(struct nvram_parser *nvp) nvp->multi_dev_v1 = true; if (strncmp(&nvp->fwnv->data[nvp->entry], "pcie/", 5) == 0) nvp->multi_dev_v2 = true; - } else if (!is_nvram_char(c)) { + } else if (!is_nvram_char(c) || c == ' ') { brcmf_dbg(INFO, "warning: ln=%d:col=%d: '=' expected, skip invalid key entry\n", nvp->line, nvp->column); return COMMENT;