From patchwork Wed May 20 11:59:54 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: 6445231 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 17C989F318 for ; Wed, 20 May 2015 12:00:15 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 2893B202FF for ; Wed, 20 May 2015 12:00:14 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 381CC202FE for ; Wed, 20 May 2015 12:00:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752681AbbETMAM (ORCPT ); Wed, 20 May 2015 08:00:12 -0400 Received: from mail-wg0-f47.google.com ([74.125.82.47]:35234 "EHLO mail-wg0-f47.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751504AbbETMAK (ORCPT ); Wed, 20 May 2015 08:00:10 -0400 Received: by wgfl8 with SMTP id l8so50306941wgf.2 for ; Wed, 20 May 2015 05:00:09 -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:mime-version:content-type :content-transfer-encoding; bh=8Gkdvx+g5yNg9Qa4itjmlZpQl5HnisvhzZZgcukNm3k=; b=bjpbzSz+4kb/BDTkvoNmGUa0+vAQ8KIeC0yTpoToQG9gvWZXHDpbjQy2i0mwMLT+9K f4J+dlpY7xfEzGfyWt1wrDB0pUzFIo12rDNgVdlqEMevmCPrJfvGsou31W0wdQcpMo// YcO4hOIwWWDiyA0WKhvY1rtgOXYGX40caT30xHl1IEOk2E7mJOGMM7stxOCRiSHfR45R w0j/dpQ1GlgMe0MuFf32JcDq0GOXqsK4rO/BuFWq0lbkNsQM+nmuymW9tmpRvldCCwoG p+OBLGi4fl1+mxarLFo5B4zG8Y+Wollxln8SaEx3oTzu98570A1Wig8ypBB38to1GmQh UDIA== X-Received: by 10.180.187.170 with SMTP id ft10mr7061710wic.75.1432123208963; Wed, 20 May 2015 05:00:08 -0700 (PDT) Received: from linux-tdhb.lan ([194.187.74.233]) by mx.google.com with ESMTPSA id q10sm15408497wjo.38.2015.05.20.05.00.06 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 20 May 2015 05:00:07 -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] brcmfmac: treat \0 as end of comment when parsing NVRAM Date: Wed, 20 May 2015 13:59:54 +0200 Message-Id: <1432123194-12584-1-git-send-email-zajec5@gmail.com> X-Mailer: git-send-email 1.8.4.5 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 This fixes brcmfmac dealing with NVRAM coming from platform e.g. from a flash MTD partition. In such cases entries are separated by \0 instead of \n which caused ignoring whole content after the first "comment". While platform NVRAM doesn't usually contain comments, we switch to COMMENT state after e.g. finding an unexpected char in key name. Signed-off-by: Rafa? Mi?ecki --- drivers/net/wireless/brcm80211/brcmfmac/firmware.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/drivers/net/wireless/brcm80211/brcmfmac/firmware.c b/drivers/net/wireless/brcm80211/brcmfmac/firmware.c index 0d02e31..45d7191 100644 --- a/drivers/net/wireless/brcm80211/brcmfmac/firmware.c +++ b/drivers/net/wireless/brcm80211/brcmfmac/firmware.c @@ -162,17 +162,20 @@ brcmf_nvram_handle_value(struct nvram_parser *nvp) static enum nvram_parser_state brcmf_nvram_handle_comment(struct nvram_parser *nvp) { - char *eol, *sol; + char *eoc, *sol; sol = (char *)&nvp->fwnv->data[nvp->pos]; - eol = strchr(sol, '\n'); - if (eol == NULL) - return END; + eoc = strchr(sol, '\n'); + if (!eoc) { + eoc = strchr(sol, '\0'); + if (!eoc) + return END; + } /* eat all moving to next line */ nvp->line++; nvp->column = 1; - nvp->pos += (eol - sol) + 1; + nvp->pos += (eoc - sol) + 1; return IDLE; }