From patchwork Mon Mar 9 18:03:44 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Leif Lindholm X-Patchwork-Id: 45553 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-we0-f197.google.com (mail-we0-f197.google.com [74.125.82.197]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 559F3214BF for ; Mon, 9 Mar 2015 18:02:53 +0000 (UTC) Received: by wesp10 with SMTP id p10sf5270910wes.3 for ; Mon, 09 Mar 2015 11:02:52 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:delivered-to:from:to:cc:subject :date:message-id:in-reply-to:references:sender:precedence:list-id :x-original-sender:x-original-authentication-results:mailing-list :list-post:list-help:list-archive:list-unsubscribe; bh=xUOnEbIRmk9DoeYX1DjtEWKT4DgO6HLaNNkstT2A8us=; b=IexIE6sDosliF2Z35ywj+oEAqWr4hLK3ZqRxRemKYx9wmB8WETiv/fwAF33LWW4X+N wzYOlniinn1uGUKwXx+nWvshAqbxzn9etJe3m+vFPPDmXUwwv90EuofcbnFupTi8yioU ze5EGZvBhbfzEourR9ezhsPngJ2jVMxMnNlpYGDqFn2cW+HViuC2jGOveLDzb0mXQ/DH e379j1shtv/c3wfzNAZKgG8B4mXTsN90ayoYH3bviqgCctIpTwfMQ9FmwoYxhm27pZcK lD/Yasox5R4aRH7K/d1mdjNjx5Uyk0ZCgxtSDF+xM2neDXUbQ9o9Zd02VCNekAR1638Y A97w== X-Gm-Message-State: ALoCoQkL9am/WfaZlhdyZB2AhOlS/l+EBMOjgp+nEI7GFj4Dedoh5zBwjKl7JcK7nHoC6Y2IXWzi X-Received: by 10.181.13.236 with SMTP id fb12mr4610807wid.1.1425924172671; Mon, 09 Mar 2015 11:02:52 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.204.69 with SMTP id kw5ls314512lac.86.gmail; Mon, 09 Mar 2015 11:02:52 -0700 (PDT) X-Received: by 10.153.7.69 with SMTP id da5mr27189185lad.108.1425924172437; Mon, 09 Mar 2015 11:02:52 -0700 (PDT) Received: from mail-la0-f53.google.com (mail-la0-f53.google.com. [209.85.215.53]) by mx.google.com with ESMTPS id x5si14821620lad.127.2015.03.09.11.02.52 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 09 Mar 2015 11:02:52 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.53 as permitted sender) client-ip=209.85.215.53; Received: by labhs14 with SMTP id hs14so72833496lab.4 for ; Mon, 09 Mar 2015 11:02:52 -0700 (PDT) X-Received: by 10.152.121.33 with SMTP id lh1mr27080696lab.86.1425924172336; Mon, 09 Mar 2015 11:02:52 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.112.35.133 with SMTP id h5csp1639560lbj; Mon, 9 Mar 2015 11:02:51 -0700 (PDT) X-Received: by 10.70.118.166 with SMTP id kn6mr56429863pdb.10.1425924170558; Mon, 09 Mar 2015 11:02:50 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id he4si19162795pac.34.2015.03.09.11.02.49; Mon, 09 Mar 2015 11:02:50 -0700 (PDT) Received-SPF: none (google.com: linux-kernel-owner@vger.kernel.org does not designate permitted sender hosts) client-ip=209.132.180.67; Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753867AbbCISCa (ORCPT + 28 others); Mon, 9 Mar 2015 14:02:30 -0400 Received: from mail-we0-f180.google.com ([74.125.82.180]:44641 "EHLO mail-we0-f180.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753325AbbCISC0 (ORCPT ); Mon, 9 Mar 2015 14:02:26 -0400 Received: by wesp10 with SMTP id p10so8398457wes.11 for ; Mon, 09 Mar 2015 11:02:25 -0700 (PDT) X-Received: by 10.195.11.73 with SMTP id eg9mr59104785wjd.62.1425924144946; Mon, 09 Mar 2015 11:02:24 -0700 (PDT) Received: from mohikan.mushroom.smurfnet.nu (cpc4-cmbg17-2-0-cust71.5-4.cable.virginm.net. [86.14.224.72]) by mx.google.com with ESMTPSA id cj9sm13768530wjc.42.2015.03.09.11.02.21 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 09 Mar 2015 11:02:23 -0700 (PDT) From: Leif Lindholm To: devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Cc: grant.likely@linaro.org, robh+dt@kernel.org, peter@hurleysoftware.com Subject: [PATCH 1/2] of: fix handling of '/' in options for of_find_node_by_path() Date: Mon, 9 Mar 2015 18:03:44 +0000 Message-Id: <1425924225-22748-2-git-send-email-leif.lindholm@linaro.org> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1425924225-22748-1-git-send-email-leif.lindholm@linaro.org> References: <1425924225-22748-1-git-send-email-leif.lindholm@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: list List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: leif.lindholm@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.53 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , Ensure proper handling of paths with appended options (after ':'), where those options may contain a '/'. Fixes: 7914a7c5651a ("of: support passing console options with stdout-path") Reported-by: Peter Hurley Signed-off-by: Leif Lindholm --- drivers/of/base.c | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/drivers/of/base.c b/drivers/of/base.c index 0a8aeb8..8b904e5 100644 --- a/drivers/of/base.c +++ b/drivers/of/base.c @@ -714,16 +714,17 @@ static struct device_node *__of_find_node_by_path(struct device_node *parent, const char *path) { struct device_node *child; - int len = strchrnul(path, '/') - path; - int term; + int len; + const char *end; + end = strchr(path, ':'); + if (!end) + end = strchrnul(path, '/'); + + len = end - path; if (!len) return NULL; - term = strchrnul(path, ':') - path; - if (term < len) - len = term; - __for_each_child_of_node(parent, child) { const char *name = strrchr(child->full_name, '/'); if (WARN(!name, "malformed device_node %s\n", child->full_name)) @@ -768,8 +769,12 @@ struct device_node *of_find_node_opts_by_path(const char *path, const char **opt /* The path could begin with an alias */ if (*path != '/') { - char *p = strchrnul(path, '/'); - int len = separator ? separator - path : p - path; + int len; + const char *p = separator; + + if (!p) + p = strchrnul(path, '/'); + len = p - path; /* of_aliases must not be NULL */ if (!of_aliases) @@ -794,6 +799,8 @@ struct device_node *of_find_node_opts_by_path(const char *path, const char **opt path++; /* Increment past '/' delimiter */ np = __of_find_node_by_path(np, path); path = strchrnul(path, '/'); + if (separator && separator < path) + break; } raw_spin_unlock_irqrestore(&devtree_lock, flags); return np;