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: 5970481 Return-Path: X-Original-To: patchwork-linux-arm@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 21A859F2A9 for ; Mon, 9 Mar 2015 18:05:22 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 5B5A220266 for ; Mon, 9 Mar 2015 18:05:21 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 8ED73202B8 for ; Mon, 9 Mar 2015 18:05:19 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1YV21M-0002NE-1n; Mon, 09 Mar 2015 18:03:16 +0000 Received: from mail-wi0-f169.google.com ([209.85.212.169]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1YV20s-00021j-Up for linux-arm-kernel@lists.infradead.org; Mon, 09 Mar 2015 18:02:47 +0000 Received: by wivr20 with SMTP id r20so23748169wiv.3 for ; Mon, 09 Mar 2015 11:02:25 -0700 (PDT) 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; bh=JTKdpEguwzyiF5yLD99+rxY6TTlpJNHbd9dVpzOSDrQ=; b=jZzLh0w37Oh+lIsiKpIMgRguOHIA+tGSp9EKuR+C2362QbNvsI0F/HyztsnkttVCdY Qry1XptD1nMzdt/Un6vuh7KEchtZNQSPBisICFVI4k0NhubEbbmI7sHyoizzk+DAYmmw ZlYKniaf+5zKYoQaUrXAXLII3dFNi1AJR54ZYKy7xSg4mbonpJJQiCByXvcbk58cp68S Trwx0TM223gm4Pxji9Bz+Bxy4hkeXb5nr99GIXUxqxdp3KM5YZiF5YtpOF5L/enYEGEA ADC9AxtN/EEwPYZQHu8QHcw3YkTY2EKj9MBg/Jd+Ig47pu3RI0vZhjkidC2UZ0DrKe7N A+Ww== X-Gm-Message-State: ALoCoQmd38nVdYIf+arUtbk0rpdmZm9mSleJmtHWB/1xQxrEqF6CBX8xRMdrD/+sUBgNaN87ut2v 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 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> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20150309_110247_188241_BD386310 X-CRM114-Status: GOOD ( 13.21 ) X-Spam-Score: -0.7 (/) Cc: grant.likely@linaro.org, robh+dt@kernel.org, peter@hurleysoftware.com X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable 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 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;