{"id":2219797,"url":"http://patchwork.ozlabs.org/api/patches/2219797/?format=json","web_url":"http://patchwork.ozlabs.org/project/sparclinux/patch/20260404190003.3-sparc-prom-pengpeng@iscas.ac.cn/","project":{"id":10,"url":"http://patchwork.ozlabs.org/api/projects/10/?format=json","name":"Linux SPARC Development ","link_name":"sparclinux","list_id":"sparclinux.vger.kernel.org","list_email":"sparclinux@vger.kernel.org","web_url":null,"scm_url":null,"webscm_url":null,"list_archive_url":"","list_archive_url_format":"","commit_url_format":""},"msgid":"<20260404190003.3-sparc-prom-pengpeng@iscas.ac.cn>","list_archive_url":null,"date":"2026-04-04T09:32:20","name":"sparc/prom: size path-component buffers to fit node names","commit_ref":null,"pull_url":null,"state":"new","archived":false,"hash":"700652c31eddd4923ec0681cc9df0a60db89a206","submitter":{"id":93000,"url":"http://patchwork.ozlabs.org/api/people/93000/?format=json","name":"Pengpeng Hou","email":"pengpeng@iscas.ac.cn"},"delegate":null,"mbox":"http://patchwork.ozlabs.org/project/sparclinux/patch/20260404190003.3-sparc-prom-pengpeng@iscas.ac.cn/mbox/","series":[{"id":498728,"url":"http://patchwork.ozlabs.org/api/series/498728/?format=json","web_url":"http://patchwork.ozlabs.org/project/sparclinux/list/?series=498728","date":"2026-04-04T09:32:20","name":"sparc/prom: size path-component buffers to fit node names","version":1,"mbox":"http://patchwork.ozlabs.org/series/498728/mbox/"}],"comments":"http://patchwork.ozlabs.org/api/patches/2219797/comments/","check":"pending","checks":"http://patchwork.ozlabs.org/api/patches/2219797/checks/","tags":{},"related":[],"headers":{"Return-Path":"\n <SRS0=1tE+=CD=vger.kernel.org=sparclinux+bounces-6637-patchwork-incoming=ozlabs.org@ozlabs.org>","X-Original-To":["incoming@patchwork.ozlabs.org","sparclinux@vger.kernel.org"],"Delivered-To":["patchwork-incoming@legolas.ozlabs.org","patchwork-incoming@ozlabs.org"],"Authentication-Results":["legolas.ozlabs.org;\n spf=pass (sender SPF authorized) smtp.mailfrom=ozlabs.org\n (client-ip=150.107.74.76; helo=mail.ozlabs.org;\n envelope-from=srs0=1te+=cd=vger.kernel.org=sparclinux+bounces-6637-patchwork-incoming=ozlabs.org@ozlabs.org;\n receiver=patchwork.ozlabs.org)","gandalf.ozlabs.org;\n arc=pass smtp.remote-ip=104.64.211.4 arc.chain=subspace.kernel.org","gandalf.ozlabs.org;\n dmarc=none (p=none dis=none) header.from=iscas.ac.cn","gandalf.ozlabs.org;\n spf=pass (sender SPF authorized) smtp.mailfrom=vger.kernel.org\n (client-ip=104.64.211.4; helo=sin.lore.kernel.org;\n envelope-from=sparclinux+bounces-6637-patchwork-incoming=ozlabs.org@vger.kernel.org;\n receiver=ozlabs.org)","smtp.subspace.kernel.org;\n arc=none smtp.client-ip=159.226.251.81","smtp.subspace.kernel.org;\n dmarc=none (p=none dis=none) header.from=iscas.ac.cn","smtp.subspace.kernel.org;\n spf=pass smtp.mailfrom=iscas.ac.cn"],"Received":["from mail.ozlabs.org (gandalf.ozlabs.org [150.107.74.76])\n\t(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)\n\t key-exchange x25519 server-signature ECDSA (secp384r1 raw public key)\n server-digest SHA384)\n\t(No client certificate requested)\n\tby legolas.ozlabs.org (Postfix) with ESMTPS id 4fnxtY6gZFz1xtJ\n\tfor <incoming@patchwork.ozlabs.org>; Sun, 05 Apr 2026 00:55:16 +1100 (AEDT)","from mail.ozlabs.org (mail.ozlabs.org [IPv6:2404:9400:2221:ea00::3])\n\tby gandalf.ozlabs.org (Postfix) with ESMTP id 4fnxtX4Twgz4wHf\n\tfor <incoming@patchwork.ozlabs.org>; Sun, 05 Apr 2026 00:55:16 +1100 (AEDT)","by gandalf.ozlabs.org (Postfix)\n\tid 4fnxtR439Jz4w1f; Sun, 05 Apr 2026 00:55:11 +1100 (AEDT)","from sin.lore.kernel.org (sin.lore.kernel.org [104.64.211.4])\n\t(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)\n\t key-exchange x25519)\n\t(No client certificate requested)\n\tby gandalf.ozlabs.org (Postfix) with ESMTPS id 4fnxtM5nxHz4w1W\n\tfor <patchwork-incoming@ozlabs.org>; Sun, 05 Apr 2026 00:55:07 +1100 (AEDT)","from smtp.subspace.kernel.org (conduit.subspace.kernel.org\n [100.90.174.1])\n\tby sin.lore.kernel.org (Postfix) with ESMTP id 9EFA430069BE\n\tfor <patchwork-incoming@ozlabs.org>; Sat,  4 Apr 2026 13:55:03 +0000 (UTC)","from localhost.localdomain (localhost.localdomain [127.0.0.1])\n\tby smtp.subspace.kernel.org (Postfix) with ESMTP id 5C1DD264617;\n\tSat,  4 Apr 2026 13:55:00 +0000 (UTC)","from cstnet.cn (smtp81.cstnet.cn [159.226.251.81])\n\t(using TLSv1.2 with cipher DHE-RSA-AES256-SHA (256/256 bits))\n\t(No client certificate requested)\n\tby smtp.subspace.kernel.org (Postfix) with ESMTPS id 07D3061FFE;\n\tSat,  4 Apr 2026 13:54:55 +0000 (UTC)","from 0003-sparc-prom.eml (unknown [111.196.245.197])\n\tby APP-03 (Coremail) with SMTP id rQCowAA3VdwmGNFpyyvfDA--.50966S2;\n\tSat, 04 Apr 2026 21:54:46 +0800 (CST)"],"ARC-Seal":["i=2; a=rsa-sha256; d=ozlabs.org; s=201707; t=1775310911; cv=pass;\n\tb=OKRIedeDgrud3AErcTDB9xJ30Almfgwx3T2kaiFNFD7weZEcpQk5t1W1Oqm4oo6lo+rvrlND1iiFCcb/GxZjnsAm30DnYlmdLrRRhuflQ4ROG9yyEYkXSOEHmDOCdgOOsoIesdShTyE7aKPnL2CzM0I9Y8ZJejkZEoN89md//OD0jGaFoPYLKbdASxiWHWftvrvVFkzoTLL2Sk/OFxelln16TsYVgFIx1V9n4ZTxtRTKzONoizkBS3gDWPkNKjUUS51r0g5VQ1Hn3790+qjbH51W4TQx5LY4gtqwRtcTqxc0f+Gn34d8yIBWZjF3wDcG9RvcpjnXIG+pqgnfxQcWHQ==","i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116;\n\tt=1775310900; cv=none;\n b=e9ChpKy9H/Tsn8oSBYu1Zb5x73rWVYAWckoFGB+4dmYXJO7p6AmbZck10A0sTKMfXv7tET07xK9vd2hD7M1Y7Yp8w458hYsGUakR0Y9gSXgDyYo1DOvdIy5j+ZQBYA/3Zwd9/prdNhSmtX5KZLuMCKAnWx0RO0vSutW4naR7FiM="],"ARC-Message-Signature":["i=2; a=rsa-sha256; d=ozlabs.org; s=201707;\n\tt=1775310911; c=relaxed/relaxed;\n\tbh=BP6fYm/AjSOGRjLpLgwkzVXTO0qJRZaanZfsWDyzgO0=;\n\th=From:Date:Message-ID:To:Cc:Subject;\n b=DKvFcqlu1uiN/tVLQH1XnZGkHz1OjoAw3LaWSgdaJ/yvtqwfAods61b+Jq+c5+99+ZTHY7VH+qpeDyIQdoWgwuyYNtYY240SyJhR/oghRLS51PuDtPcaqcxeaZk9h2LCz4Fc0im+ruEFDyCsH6y++MLWfXbs4NO2XRR/HPzSYzpiACcm56jhncluPqXyFParRmxoGykpTERE+gJSm6x+UdLoJsBXk4YS0R/JevHEfAevLA+3UXmW3ZLzE5iwCGLndR2/82AftJeRA6HI7O0VFd6c6878Xyb8VZPOCSb6/MGuwQquEPfw4RXdzvZ9CFxZ99+9mHQMGYsoo9HX+nm6Ig==","i=1; a=rsa-sha256; d=subspace.kernel.org;\n\ts=arc-20240116; t=1775310900; c=relaxed/simple;\n\tbh=dQSzIADc6sP5vJjxkJmrIIMyUJ0eKm79JNtVfcJUQLc=;\n\th=From:Date:Message-ID:To:Cc:Subject;\n b=dn+StjzAqWePim4VEUkaX7wTi+JqhHVxbnANdL0kJehOsR8qF1JVyubEv2xqfhOcFl5IxjJ97X6487Zjky+nCugUpZP+HTTGkGSoP2IeYdib9WSlQ4pa2s0eAywSj/6NbjlI23z4XxvseSOBnfEDV2zTmNDl9in409CWOuSudvE="],"ARC-Authentication-Results":["i=2; gandalf.ozlabs.org;\n dmarc=none (p=none dis=none) header.from=iscas.ac.cn;\n spf=pass (client-ip=104.64.211.4; helo=sin.lore.kernel.org;\n envelope-from=sparclinux+bounces-6637-patchwork-incoming=ozlabs.org@vger.kernel.org;\n receiver=ozlabs.org) smtp.mailfrom=vger.kernel.org","i=1; smtp.subspace.kernel.org;\n dmarc=none (p=none dis=none) header.from=iscas.ac.cn;\n spf=pass smtp.mailfrom=iscas.ac.cn; arc=none smtp.client-ip=159.226.251.81"],"From":"Pengpeng Hou <pengpeng@iscas.ac.cn>","Date":"Sat, 4 Apr 2026 17:32:20 +0800","Message-ID":"<20260404190003.3-sparc-prom-pengpeng@iscas.ac.cn>","To":"\"David S. Miller\" <davem@davemloft.net>,\n Andreas Larsson <andreas@gaisler.com>, sparclinux@vger.kernel.org","Cc":"linux-kernel@vger.kernel.org, pengpeng@iscas.ac.cn","Subject":"[PATCH] sparc/prom: size path-component buffers to fit node names","X-CM-TRANSID":"rQCowAA3VdwmGNFpyyvfDA--.50966S2","X-Coremail-Antispam":"1UD129KBjvAXoWfGr1Dur4rXw18KryUZryfXrb_yoW8Cr17Go\n\tW3WwnYqw18AF4S9rWkG3Z8trZ8Z3W5Wr93AFn5Ja1DZFy7AF909FyxAa9xXa4qqr4xGasx\n\tZFsaq3yDGr97Wr4xn29KB7ZKAUJUUUU8529EdanIXcx71UUUUU7v73VFW2AGmfu7bjvjm3\n\tAaLaJ3UjIYCTnIWjp_UUUYT7AC8VAFwI0_Jr0_Gr1l1xkIjI8I6I8E6xAIw20EY4v20xva\n\tj40_Wr0E3s1l1IIY67AEw4v_Jr0_Jr4l87I20VAvwVCjjxC26r1F6r13M28lY4IEw2IIxx\n\tk0rwA2F7IY1VAKz4vEj48ve4kI8wA2z4x0Y4vE2Ix0cI8IcVAFwI0_Gr0_Xr1l84ACjcxK\n\t6xIIjxv20xvEc7CjxVAFwI0_Gr0_Cr1l84ACjcxK6I8E87Iv67AKxVW0oVCq3wA2z4x0Y4\n\tvEx4A2jsIEc7CjxVAFwI0_GcCE3s1le2I262IYc4CY6c8Ij28IcVAaY2xG8wAqx4xG64xv\n\tF2IEw4CE5I8CrVC2j2WlYx0E2Ix0cI8IcVAFwI0_Jrv_JF1lYx0Ex4A2jsIE14v26r1j6r\n\t4UMcvjeVCFs4IE7xkEbVWUJVW8JwACjcxG0xvEwIxGrwACjI8F5VA0II8E6IAqYI8I648v\n\t4I1lc7CjxVAaw2AFwI0_JF0_Jw1l42xK82IYc2Ij64vIr41l4I8I3I0E4IkC6x0Yz7v_Jr\n\t0_Gr1lx2IqxVAqx4xG67AKxVWUJVWUGwC20s026x8GjcxK67AKxVWUGVWUWwC2zVAF1VAY\n\t17CE14v26r126r1DMIIYrxkI7VAKI48JMIIF0xvE2Ix0cI8IcVAFwI0_Jr0_JF4lIxAIcV\n\tC0I7IYx2IY6xkF7I0E14v26r4j6F4UMIIF0xvE42xK8VAvwI8IcIk0rVWUJVWUCwCI42IY\n\t6I8E87Iv67AKxVWUJVW8JwCI42IY6I8E87Iv6xkF7I0E14v26r4j6r4UJbIYCTnIWIevJa\n\t73UjIFyTuYvjfU5oGQDUUUU","X-CM-SenderInfo":"pshqw1xhqjqxpvfd2hldfou0/","Precedence":"bulk","X-Mailing-List":"sparclinux@vger.kernel.org","List-Id":"<sparclinux.vger.kernel.org>","List-Subscribe":"<mailto:sparclinux+subscribe@vger.kernel.org>","List-Unsubscribe":"<mailto:sparclinux+unsubscribe@vger.kernel.org>","X-Spam-Status":"No, score=0.1 required=5.0 tests=ARC_SIGNED,ARC_VALID,\n\tDATE_IN_PAST_03_06,DMARC_MISSING,HEADER_FROM_DIFFERENT_DOMAINS,\n\tMAILING_LIST_MULTI,NORMAL_HTTP_TO_IP,NUMERIC_HTTP_ADDR,SPF_HELO_NONE,\n\tSPF_PASS,URI_HEX autolearn=disabled version=4.0.1","X-Spam-Checker-Version":"SpamAssassin 4.0.1 (2024-03-25) on gandalf.ozlabs.org"},"content":"build_path_component() in both sparc PROM variants formats fully-named\npath components in a fixed 64-byte local buffer and feeds raw firmware\nnode names\ninto a chain of sprintf() helpers.\n\nThat leaves two problems in the current tree: malformed or unterminated\nname properties are treated as C strings, and long node names can\noverflow the fixed local scratch buffer before the formatted path\ncomponent is copied into early memory.\n\nRead the node name with of_property_read_string(), size the destination\nbuffer from the validated name length plus the maximum address suffix, and\nuse bounded formatting in the helper chain.\n\nSigned-off-by: Pengpeng Hou <pengpeng@iscas.ac.cn>\n---\n arch/sparc/kernel/prom_32.c |  84 +++++++++---------\n arch/sparc/kernel/prom_64.c | 172 +++++++++++++++++-------------------\n 2 files changed, 122 insertions(+), 134 deletions(-)","diff":"diff --git a/arch/sparc/kernel/prom_32.c b/arch/sparc/kernel/prom_32.c\nindex cd94f1e8d644..b2a717a44105 100644\n--- a/arch/sparc/kernel/prom_32.c\n+++ b/arch/sparc/kernel/prom_32.c\n@@ -16,6 +16,7 @@\n #include <linux/string.h>\n #include <linux/mm.h>\n #include <linux/memblock.h>\n+#include <linux/of.h>\n \n #include <asm/prom.h>\n #include <asm/oplib.h>\n@@ -24,6 +25,8 @@\n \n #include \"prom.h\"\n \n+#define SPARC_PATH_COMPONENT_EXTRA 32\n+\n void * __init prom_early_alloc(unsigned long size)\n {\n \tvoid *ret;\n@@ -52,9 +55,10 @@ void * __init prom_early_alloc(unsigned long size)\n  * we walk up the tree until we discover a \"device_type\" property\n  * we recognize and we go from there.\n  */\n-static void __init sparc32_path_component(struct device_node *dp, char *tmp_buf)\n+static void __init sparc32_path_component(const char *name,\n+\t\t\t\t\t  struct device_node *dp,\n+\t\t\t\t\t  char *tmp_buf, size_t len)\n {\n-\tconst char *name = of_get_property(dp, \"name\", NULL);\n \tstruct linux_prom_registers *regs;\n \tstruct property *rprop;\n \n@@ -63,15 +67,14 @@ static void __init sparc32_path_component(struct device_node *dp, char *tmp_buf)\n \t\treturn;\n \n \tregs = rprop->value;\n-\tsprintf(tmp_buf, \"%s@%x,%x\",\n-\t\tname,\n-\t\tregs->which_io, regs->phys_addr);\n+\tscnprintf(tmp_buf, len, \"%s@%x,%x\",\n+\t\t  name, regs->which_io, regs->phys_addr);\n }\n \n /* \"name@slot,offset\"  */\n-static void __init sbus_path_component(struct device_node *dp, char *tmp_buf)\n+static void __init sbus_path_component(const char *name, struct device_node *dp,\n+\t\t\t\t       char *tmp_buf, size_t len)\n {\n-\tconst char *name = of_get_property(dp, \"name\", NULL);\n \tstruct linux_prom_registers *regs;\n \tstruct property *prop;\n \n@@ -80,16 +83,14 @@ static void __init sbus_path_component(struct device_node *dp, char *tmp_buf)\n \t\treturn;\n \n \tregs = prop->value;\n-\tsprintf(tmp_buf, \"%s@%x,%x\",\n-\t\tname,\n-\t\tregs->which_io,\n-\t\tregs->phys_addr);\n+\tscnprintf(tmp_buf, len, \"%s@%x,%x\",\n+\t\t  name, regs->which_io, regs->phys_addr);\n }\n \n /* \"name@devnum[,func]\" */\n-static void __init pci_path_component(struct device_node *dp, char *tmp_buf)\n+static void __init pci_path_component(const char *name, struct device_node *dp,\n+\t\t\t\t      char *tmp_buf, size_t len)\n {\n-\tconst char *name = of_get_property(dp, \"name\", NULL);\n \tstruct linux_prom_pci_registers *regs;\n \tstruct property *prop;\n \tunsigned int devfn;\n@@ -101,21 +102,17 @@ static void __init pci_path_component(struct device_node *dp, char *tmp_buf)\n \tregs = prop->value;\n \tdevfn = (regs->phys_hi >> 8) & 0xff;\n \tif (devfn & 0x07) {\n-\t\tsprintf(tmp_buf, \"%s@%x,%x\",\n-\t\t\tname,\n-\t\t\tdevfn >> 3,\n-\t\t\tdevfn & 0x07);\n+\t\tscnprintf(tmp_buf, len, \"%s@%x,%x\",\n+\t\t\t  name, devfn >> 3, devfn & 0x07);\n \t} else {\n-\t\tsprintf(tmp_buf, \"%s@%x\",\n-\t\t\tname,\n-\t\t\tdevfn >> 3);\n+\t\tscnprintf(tmp_buf, len, \"%s@%x\", name, devfn >> 3);\n \t}\n }\n \n /* \"name@addrhi,addrlo\" */\n-static void __init ebus_path_component(struct device_node *dp, char *tmp_buf)\n+static void __init ebus_path_component(const char *name, struct device_node *dp,\n+\t\t\t\t       char *tmp_buf, size_t len)\n {\n-\tconst char *name = of_get_property(dp, \"name\", NULL);\n \tstruct linux_prom_registers *regs;\n \tstruct property *prop;\n \n@@ -125,15 +122,15 @@ static void __init ebus_path_component(struct device_node *dp, char *tmp_buf)\n \n \tregs = prop->value;\n \n-\tsprintf(tmp_buf, \"%s@%x,%x\",\n-\t\tname,\n-\t\tregs->which_io, regs->phys_addr);\n+\tscnprintf(tmp_buf, len, \"%s@%x,%x\",\n+\t\t  name, regs->which_io, regs->phys_addr);\n }\n \n /* \"name@irq,addrlo\" */\n-static void __init ambapp_path_component(struct device_node *dp, char *tmp_buf)\n+static void __init ambapp_path_component(const char *name,\n+\t\t\t\t\t struct device_node *dp,\n+\t\t\t\t\t char *tmp_buf, size_t len)\n {\n-\tconst char *name = of_get_property(dp, \"name\", NULL);\n \tstruct amba_prom_registers *regs;\n \tunsigned int *intr;\n \tunsigned int reg0;\n@@ -158,45 +155,46 @@ static void __init ambapp_path_component(struct device_node *dp, char *tmp_buf)\n \telse\n \t\tintr = prop->value;\n \n-\tsprintf(tmp_buf, \"%s@%x,%x\", name, *intr, reg0);\n+\tscnprintf(tmp_buf, len, \"%s@%x,%x\", name, *intr, reg0);\n }\n \n-static void __init __build_path_component(struct device_node *dp, char *tmp_buf)\n+static void __init __build_path_component(const char *name,\n+\t\t\t\t\t  struct device_node *dp,\n+\t\t\t\t\t  char *tmp_buf, size_t len)\n {\n \tstruct device_node *parent = dp->parent;\n \n \tif (parent != NULL) {\n \t\tif (of_node_is_type(parent, \"pci\") ||\n \t\t    of_node_is_type(parent, \"pciex\"))\n-\t\t\treturn pci_path_component(dp, tmp_buf);\n+\t\t\treturn pci_path_component(name, dp, tmp_buf, len);\n \t\tif (of_node_is_type(parent, \"sbus\"))\n-\t\t\treturn sbus_path_component(dp, tmp_buf);\n+\t\t\treturn sbus_path_component(name, dp, tmp_buf, len);\n \t\tif (of_node_is_type(parent, \"ebus\"))\n-\t\t\treturn ebus_path_component(dp, tmp_buf);\n+\t\t\treturn ebus_path_component(name, dp, tmp_buf, len);\n \t\tif (of_node_is_type(parent, \"ambapp\"))\n-\t\t\treturn ambapp_path_component(dp, tmp_buf);\n+\t\t\treturn ambapp_path_component(name, dp, tmp_buf, len);\n \n \t\t/* \"isa\" is handled with platform naming */\n \t}\n \n \t/* Use platform naming convention.  */\n-\treturn sparc32_path_component(dp, tmp_buf);\n+\treturn sparc32_path_component(name, dp, tmp_buf, len);\n }\n \n char * __init build_path_component(struct device_node *dp)\n {\n-\tconst char *name = of_get_property(dp, \"name\", NULL);\n-\tchar tmp_buf[64], *n;\n+\tconst char *name = \"\";\n+\tchar *n;\n \tsize_t n_sz;\n \n-\ttmp_buf[0] = '\\0';\n-\t__build_path_component(dp, tmp_buf);\n-\tif (tmp_buf[0] == '\\0')\n-\t\tstrscpy(tmp_buf, name);\n-\n-\tn_sz = strlen(tmp_buf) + 1;\n+\tof_property_read_string(dp, \"name\", &name);\n+\tn_sz = strlen(name) + SPARC_PATH_COMPONENT_EXTRA;\n \tn = prom_early_alloc(n_sz);\n-\tstrscpy(n, tmp_buf, n_sz);\n+\tn[0] = '\\0';\n+\t__build_path_component(name, dp, n, n_sz);\n+\tif (n[0] == '\\0')\n+\t\tstrscpy(n, name, n_sz);\n \n \treturn n;\n }\ndiff --git a/arch/sparc/kernel/prom_64.c b/arch/sparc/kernel/prom_64.c\nindex aa4799cbb9c1..e8053cf545ea 100644\n--- a/arch/sparc/kernel/prom_64.c\n+++ b/arch/sparc/kernel/prom_64.c\n@@ -28,6 +28,8 @@\n \n #include \"prom.h\"\n \n+#define SPARC_PATH_COMPONENT_EXTRA 32\n+\n void * __init prom_early_alloc(unsigned long size)\n {\n \tvoid *ret = memblock_alloc(size, SMP_CACHE_BYTES);\n@@ -63,9 +65,10 @@ void * __init prom_early_alloc(unsigned long size)\n  *\n  *\t/pci@1e,600000/ide@d/disk@0,0:c\n  */\n-static void __init sun4v_path_component(struct device_node *dp, char *tmp_buf)\n+static void __init sun4v_path_component(const char *name,\n+\t\t\t\t\tstruct device_node *dp,\n+\t\t\t\t\tchar *tmp_buf, size_t len)\n {\n-\tconst char *name = of_get_property(dp, \"name\", NULL);\n \tstruct linux_prom64_registers *regs;\n \tstruct property *rprop;\n \tu32 high_bits, low_bits, type;\n@@ -76,10 +79,10 @@ static void __init sun4v_path_component(struct device_node *dp, char *tmp_buf)\n \n \tregs = rprop->value;\n \tif (!of_node_is_root(dp->parent)) {\n-\t\tsprintf(tmp_buf, \"%s@%x,%x\",\n-\t\t\tname,\n-\t\t\t(unsigned int) (regs->phys_addr >> 32UL),\n-\t\t\t(unsigned int) (regs->phys_addr & 0xffffffffUL));\n+\t\tscnprintf(tmp_buf, len, \"%s@%x,%x\",\n+\t\t\t  name,\n+\t\t\t  (unsigned int)(regs->phys_addr >> 32UL),\n+\t\t\t  (unsigned int)(regs->phys_addr & 0xffffffffUL));\n \t\treturn;\n \t}\n \n@@ -91,23 +94,20 @@ static void __init sun4v_path_component(struct device_node *dp, char *tmp_buf)\n \t\tconst char *prefix = (type == 0) ? \"m\" : \"i\";\n \n \t\tif (low_bits)\n-\t\t\tsprintf(tmp_buf, \"%s@%s%x,%x\",\n-\t\t\t\tname, prefix,\n-\t\t\t\thigh_bits, low_bits);\n+\t\t\tscnprintf(tmp_buf, len, \"%s@%s%x,%x\",\n+\t\t\t\t  name, prefix, high_bits, low_bits);\n \t\telse\n-\t\t\tsprintf(tmp_buf, \"%s@%s%x\",\n-\t\t\t\tname,\n-\t\t\t\tprefix,\n-\t\t\t\thigh_bits);\n+\t\t\tscnprintf(tmp_buf, len, \"%s@%s%x\",\n+\t\t\t\t  name, prefix, high_bits);\n \t} else if (type == 12) {\n-\t\tsprintf(tmp_buf, \"%s@%x\",\n-\t\t\tname, high_bits);\n+\t\tscnprintf(tmp_buf, len, \"%s@%x\", name, high_bits);\n \t}\n }\n \n-static void __init sun4u_path_component(struct device_node *dp, char *tmp_buf)\n+static void __init sun4u_path_component(const char *name,\n+\t\t\t\t\tstruct device_node *dp,\n+\t\t\t\t\tchar *tmp_buf, size_t len)\n {\n-\tconst char *name = of_get_property(dp, \"name\", NULL);\n \tstruct linux_prom64_registers *regs;\n \tstruct property *prop;\n \n@@ -117,10 +117,10 @@ static void __init sun4u_path_component(struct device_node *dp, char *tmp_buf)\n \n \tregs = prop->value;\n \tif (!of_node_is_root(dp->parent)) {\n-\t\tsprintf(tmp_buf, \"%s@%x,%x\",\n-\t\t\tname,\n-\t\t\t(unsigned int) (regs->phys_addr >> 32UL),\n-\t\t\t(unsigned int) (regs->phys_addr & 0xffffffffUL));\n+\t\tscnprintf(tmp_buf, len, \"%s@%x,%x\",\n+\t\t\t  name,\n+\t\t\t  (unsigned int)(regs->phys_addr >> 32UL),\n+\t\t\t  (unsigned int)(regs->phys_addr & 0xffffffffUL));\n \t\treturn;\n \t}\n \n@@ -133,17 +133,16 @@ static void __init sun4u_path_component(struct device_node *dp, char *tmp_buf)\n \t\tif (tlb_type >= cheetah)\n \t\t\tmask = 0x7fffff;\n \n-\t\tsprintf(tmp_buf, \"%s@%x,%x\",\n-\t\t\tname,\n-\t\t\t*(u32 *)prop->value,\n-\t\t\t(unsigned int) (regs->phys_addr & mask));\n+\t\tscnprintf(tmp_buf, len, \"%s@%x,%x\",\n+\t\t\t  name, *(u32 *)prop->value,\n+\t\t\t  (unsigned int)(regs->phys_addr & mask));\n \t}\n }\n \n /* \"name@slot,offset\"  */\n-static void __init sbus_path_component(struct device_node *dp, char *tmp_buf)\n+static void __init sbus_path_component(const char *name, struct device_node *dp,\n+\t\t\t\t       char *tmp_buf, size_t len)\n {\n-\tconst char *name = of_get_property(dp, \"name\", NULL);\n \tstruct linux_prom_registers *regs;\n \tstruct property *prop;\n \n@@ -152,16 +151,14 @@ static void __init sbus_path_component(struct device_node *dp, char *tmp_buf)\n \t\treturn;\n \n \tregs = prop->value;\n-\tsprintf(tmp_buf, \"%s@%x,%x\",\n-\t\tname,\n-\t\tregs->which_io,\n-\t\tregs->phys_addr);\n+\tscnprintf(tmp_buf, len, \"%s@%x,%x\",\n+\t\t  name, regs->which_io, regs->phys_addr);\n }\n \n /* \"name@devnum[,func]\" */\n-static void __init pci_path_component(struct device_node *dp, char *tmp_buf)\n+static void __init pci_path_component(const char *name, struct device_node *dp,\n+\t\t\t\t      char *tmp_buf, size_t len)\n {\n-\tconst char *name = of_get_property(dp, \"name\", NULL);\n \tstruct linux_prom_pci_registers *regs;\n \tstruct property *prop;\n \tunsigned int devfn;\n@@ -173,21 +170,17 @@ static void __init pci_path_component(struct device_node *dp, char *tmp_buf)\n \tregs = prop->value;\n \tdevfn = (regs->phys_hi >> 8) & 0xff;\n \tif (devfn & 0x07) {\n-\t\tsprintf(tmp_buf, \"%s@%x,%x\",\n-\t\t\tname,\n-\t\t\tdevfn >> 3,\n-\t\t\tdevfn & 0x07);\n+\t\tscnprintf(tmp_buf, len, \"%s@%x,%x\",\n+\t\t\t  name, devfn >> 3, devfn & 0x07);\n \t} else {\n-\t\tsprintf(tmp_buf, \"%s@%x\",\n-\t\t\tname,\n-\t\t\tdevfn >> 3);\n+\t\tscnprintf(tmp_buf, len, \"%s@%x\", name, devfn >> 3);\n \t}\n }\n \n /* \"name@UPA_PORTID,offset\" */\n-static void __init upa_path_component(struct device_node *dp, char *tmp_buf)\n+static void __init upa_path_component(const char *name, struct device_node *dp,\n+\t\t\t\t      char *tmp_buf, size_t len)\n {\n-\tconst char *name = of_get_property(dp, \"name\", NULL);\n \tstruct linux_prom64_registers *regs;\n \tstruct property *prop;\n \n@@ -201,16 +194,15 @@ static void __init upa_path_component(struct device_node *dp, char *tmp_buf)\n \tif (!prop)\n \t\treturn;\n \n-\tsprintf(tmp_buf, \"%s@%x,%x\",\n-\t\tname,\n-\t\t*(u32 *) prop->value,\n-\t\t(unsigned int) (regs->phys_addr & 0xffffffffUL));\n+\tscnprintf(tmp_buf, len, \"%s@%x,%x\",\n+\t\t  name, *(u32 *)prop->value,\n+\t\t  (unsigned int)(regs->phys_addr & 0xffffffffUL));\n }\n \n /* \"name@reg\" */\n-static void __init vdev_path_component(struct device_node *dp, char *tmp_buf)\n+static void __init vdev_path_component(const char *name, struct device_node *dp,\n+\t\t\t\t       char *tmp_buf, size_t len)\n {\n-\tconst char *name = of_get_property(dp, \"name\", NULL);\n \tstruct property *prop;\n \tu32 *regs;\n \n@@ -220,13 +212,13 @@ static void __init vdev_path_component(struct device_node *dp, char *tmp_buf)\n \n \tregs = prop->value;\n \n-\tsprintf(tmp_buf, \"%s@%x\", name, *regs);\n+\tscnprintf(tmp_buf, len, \"%s@%x\", name, *regs);\n }\n \n /* \"name@addrhi,addrlo\" */\n-static void __init ebus_path_component(struct device_node *dp, char *tmp_buf)\n+static void __init ebus_path_component(const char *name, struct device_node *dp,\n+\t\t\t\t       char *tmp_buf, size_t len)\n {\n-\tconst char *name = of_get_property(dp, \"name\", NULL);\n \tstruct linux_prom64_registers *regs;\n \tstruct property *prop;\n \n@@ -236,16 +228,16 @@ static void __init ebus_path_component(struct device_node *dp, char *tmp_buf)\n \n \tregs = prop->value;\n \n-\tsprintf(tmp_buf, \"%s@%x,%x\",\n-\t\tname,\n-\t\t(unsigned int) (regs->phys_addr >> 32UL),\n-\t\t(unsigned int) (regs->phys_addr & 0xffffffffUL));\n+\tscnprintf(tmp_buf, len, \"%s@%x,%x\",\n+\t\t  name,\n+\t\t  (unsigned int)(regs->phys_addr >> 32UL),\n+\t\t  (unsigned int)(regs->phys_addr & 0xffffffffUL));\n }\n \n /* \"name@bus,addr\" */\n-static void __init i2c_path_component(struct device_node *dp, char *tmp_buf)\n+static void __init i2c_path_component(const char *name, struct device_node *dp,\n+\t\t\t\t      char *tmp_buf, size_t len)\n {\n-\tconst char *name = of_get_property(dp, \"name\", NULL);\n \tstruct property *prop;\n \tu32 *regs;\n \n@@ -258,14 +250,13 @@ static void __init i2c_path_component(struct device_node *dp, char *tmp_buf)\n \t/* This actually isn't right... should look at the #address-cells\n \t * property of the i2c bus node etc. etc.\n \t */\n-\tsprintf(tmp_buf, \"%s@%x,%x\",\n-\t\tname, regs[0], regs[1]);\n+\tscnprintf(tmp_buf, len, \"%s@%x,%x\", name, regs[0], regs[1]);\n }\n \n /* \"name@reg0[,reg1]\" */\n-static void __init usb_path_component(struct device_node *dp, char *tmp_buf)\n+static void __init usb_path_component(const char *name, struct device_node *dp,\n+\t\t\t\t      char *tmp_buf, size_t len)\n {\n-\tconst char *name = of_get_property(dp, \"name\", NULL);\n \tstruct property *prop;\n \tu32 *regs;\n \n@@ -276,18 +267,17 @@ static void __init usb_path_component(struct device_node *dp, char *tmp_buf)\n \tregs = prop->value;\n \n \tif (prop->length == sizeof(u32) || regs[1] == 1) {\n-\t\tsprintf(tmp_buf, \"%s@%x\",\n-\t\t\tname, regs[0]);\n+\t\tscnprintf(tmp_buf, len, \"%s@%x\", name, regs[0]);\n \t} else {\n-\t\tsprintf(tmp_buf, \"%s@%x,%x\",\n-\t\t\tname, regs[0], regs[1]);\n+\t\tscnprintf(tmp_buf, len, \"%s@%x,%x\", name, regs[0], regs[1]);\n \t}\n }\n \n /* \"name@reg0reg1[,reg2reg3]\" */\n-static void __init ieee1394_path_component(struct device_node *dp, char *tmp_buf)\n+static void __init ieee1394_path_component(const char *name,\n+\t\t\t\t\t   struct device_node *dp,\n+\t\t\t\t\t   char *tmp_buf, size_t len)\n {\n-\tconst char *name = of_get_property(dp, \"name\", NULL);\n \tstruct property *prop;\n \tu32 *regs;\n \n@@ -298,51 +288,52 @@ static void __init ieee1394_path_component(struct device_node *dp, char *tmp_buf\n \tregs = prop->value;\n \n \tif (regs[2] || regs[3]) {\n-\t\tsprintf(tmp_buf, \"%s@%08x%08x,%04x%08x\",\n-\t\t\tname, regs[0], regs[1], regs[2], regs[3]);\n+\t\tscnprintf(tmp_buf, len, \"%s@%08x%08x,%04x%08x\",\n+\t\t\t  name, regs[0], regs[1], regs[2], regs[3]);\n \t} else {\n-\t\tsprintf(tmp_buf, \"%s@%08x%08x\",\n-\t\t\tname, regs[0], regs[1]);\n+\t\tscnprintf(tmp_buf, len, \"%s@%08x%08x\", name, regs[0], regs[1]);\n \t}\n }\n \n-static void __init __build_path_component(struct device_node *dp, char *tmp_buf)\n+static void __init __build_path_component(const char *name,\n+\t\t\t\t\t  struct device_node *dp,\n+\t\t\t\t\t  char *tmp_buf, size_t len)\n {\n \tstruct device_node *parent = dp->parent;\n \n \tif (parent != NULL) {\n \t\tif (of_node_is_type(parent, \"pci\") ||\n \t\t    of_node_is_type(parent, \"pciex\")) {\n-\t\t\tpci_path_component(dp, tmp_buf);\n+\t\t\tpci_path_component(name, dp, tmp_buf, len);\n \t\t\treturn;\n \t\t}\n \t\tif (of_node_is_type(parent, \"sbus\")) {\n-\t\t\tsbus_path_component(dp, tmp_buf);\n+\t\t\tsbus_path_component(name, dp, tmp_buf, len);\n \t\t\treturn;\n \t\t}\n \t\tif (of_node_is_type(parent, \"upa\")) {\n-\t\t\tupa_path_component(dp, tmp_buf);\n+\t\t\tupa_path_component(name, dp, tmp_buf, len);\n \t\t\treturn;\n \t\t}\n \t\tif (of_node_is_type(parent, \"ebus\")) {\n-\t\t\tebus_path_component(dp, tmp_buf);\n+\t\t\tebus_path_component(name, dp, tmp_buf, len);\n \t\t\treturn;\n \t\t}\n \t\tif (of_node_name_eq(parent, \"usb\") ||\n \t\t    of_node_name_eq(parent, \"hub\")) {\n-\t\t\tusb_path_component(dp, tmp_buf);\n+\t\t\tusb_path_component(name, dp, tmp_buf, len);\n \t\t\treturn;\n \t\t}\n \t\tif (of_node_is_type(parent, \"i2c\")) {\n-\t\t\ti2c_path_component(dp, tmp_buf);\n+\t\t\ti2c_path_component(name, dp, tmp_buf, len);\n \t\t\treturn;\n \t\t}\n \t\tif (of_node_is_type(parent, \"firewire\")) {\n-\t\t\tieee1394_path_component(dp, tmp_buf);\n+\t\t\tieee1394_path_component(name, dp, tmp_buf, len);\n \t\t\treturn;\n \t\t}\n \t\tif (of_node_is_type(parent, \"virtual-devices\")) {\n-\t\t\tvdev_path_component(dp, tmp_buf);\n+\t\t\tvdev_path_component(name, dp, tmp_buf, len);\n \t\t\treturn;\n \t\t}\n \t\t/* \"isa\" is handled with platform naming */\n@@ -350,27 +341,26 @@ static void __init __build_path_component(struct device_node *dp, char *tmp_buf)\n \n \t/* Use platform naming convention.  */\n \tif (tlb_type == hypervisor) {\n-\t\tsun4v_path_component(dp, tmp_buf);\n+\t\tsun4v_path_component(name, dp, tmp_buf, len);\n \t\treturn;\n \t} else {\n-\t\tsun4u_path_component(dp, tmp_buf);\n+\t\tsun4u_path_component(name, dp, tmp_buf, len);\n \t}\n }\n \n char * __init build_path_component(struct device_node *dp)\n {\n-\tconst char *name = of_get_property(dp, \"name\", NULL);\n-\tchar tmp_buf[64], *n;\n+\tconst char *name = \"\";\n+\tchar *n;\n \tsize_t n_sz;\n \n-\ttmp_buf[0] = '\\0';\n-\t__build_path_component(dp, tmp_buf);\n-\tif (tmp_buf[0] == '\\0')\n-\t\tstrscpy(tmp_buf, name);\n-\n-\tn_sz = strlen(tmp_buf) + 1;\n+\tof_property_read_string(dp, \"name\", &name);\n+\tn_sz = strlen(name) + SPARC_PATH_COMPONENT_EXTRA;\n \tn = prom_early_alloc(n_sz);\n-\tstrscpy(n, tmp_buf, n_sz);\n+\tn[0] = '\\0';\n+\t__build_path_component(name, dp, n, n_sz);\n+\tif (n[0] == '\\0')\n+\t\tstrscpy(n, name, n_sz);\n \n \treturn n;\n }\n","prefixes":[]}