of: avoid format string parsing in kobject names
authorKees Cook <keescook@chromium.org>
Tue, 10 Jun 2014 16:57:00 +0000 (09:57 -0700)
committerRob Herring <robh@kernel.org>
Mon, 16 Jun 2014 18:31:44 +0000 (13:31 -0500)
This makes sure a format string cannot leak into the kobject name that
is constructed. (And splits the >80 character line.)

Signed-off-by: Kees Cook <keescook@chromium.org>
Signed-off-by: Rob Herring <robh@kernel.org>
drivers/of/base.c

index 8368d96ae7b44d3ce7b74b37abe3eac6cac76191..f27d922eaece0a4228eb75b42b93368d6da57a64 100644 (file)
@@ -227,7 +227,8 @@ static int __of_node_add(struct device_node *np)
        np->kobj.kset = of_kset;
        if (!np->parent) {
                /* Nodes without parents are new top level trees */
-               rc = kobject_add(&np->kobj, NULL, safe_name(&of_kset->kobj, "base"));
+               rc = kobject_add(&np->kobj, NULL, "%s",
+                                safe_name(&of_kset->kobj, "base"));
        } else {
                name = safe_name(&np->parent->kobj, kbasename(np->full_name));
                if (!name || !name[0])