]> www.pilppa.org Git - linux-2.6-omap-h63xx.git/commitdiff
[SPARC]: Fix bus_id[] string overflow.
authorDavid S. Miller <davem@sunset.davemloft.net>
Fri, 27 Oct 2006 08:03:31 +0000 (01:03 -0700)
committerDavid S. Miller <davem@sunset.davemloft.net>
Fri, 27 Oct 2006 08:03:31 +0000 (01:03 -0700)
dp->path_component_name can be larger than ->bus_id[]
so use a different naming scheme for this stuff.

Noticed by Jurij Smakov.

Signed-off-by: David S. Miller <davem@davemloft.net>
arch/sparc/kernel/ebus.c
arch/sparc/kernel/of_device.c
arch/sparc64/kernel/ebus.c
arch/sparc64/kernel/isa.c
arch/sparc64/kernel/of_device.c
drivers/sbus/sbus.c

index 75ac24d229b1dda145b04ac1f68f317e050e47b3..ba58c3a061fdaaa8ff28b457bda1cf4152c34d52 100644 (file)
@@ -237,12 +237,12 @@ void __init fill_ebus_device(struct device_node *dp, struct linux_ebus_device *d
        dev->ofdev.node = dp;
        dev->ofdev.dev.parent = &dev->bus->ofdev.dev;
        dev->ofdev.dev.bus = &ebus_bus_type;
-       strcpy(dev->ofdev.dev.bus_id, dp->path_component_name);
+       sprintf(dev->ofdev.dev.bus_id, "ebus[%08x]", dp->node);
 
        /* Register with core */
        if (of_device_register(&dev->ofdev) != 0)
                printk(KERN_DEBUG "ebus: device registration error for %s!\n",
-                      dev->ofdev.dev.bus_id);
+                      dp->path_component_name);
 
        if ((dp = dp->child) != NULL) {
                dev->children = (struct linux_ebus_child *)
@@ -332,12 +332,12 @@ void __init ebus_init(void)
                ebus->ofdev.node = dp;
                ebus->ofdev.dev.parent = &pdev->dev;
                ebus->ofdev.dev.bus = &ebus_bus_type;
-               strcpy(ebus->ofdev.dev.bus_id, dp->path_component_name);
+               sprintf(ebus->ofdev.dev.bus_id, "ebus%d", num_ebus);
 
                /* Register with core */
                if (of_device_register(&ebus->ofdev) != 0)
                        printk(KERN_DEBUG "ebus: device registration error for %s!\n",
-                              ebus->ofdev.dev.bus_id);
+                              dp->path_component_name);
 
 
                nd = dp->child;
index 74bef2a2d37f8461df87fe43ce95a5d276ad8ab9..46200c43ffb129a4ed51f3430126d927895d29f4 100644 (file)
@@ -651,7 +651,7 @@ build_resources:
        if (!parent)
                strcpy(op->dev.bus_id, "root");
        else
-               strcpy(op->dev.bus_id, dp->path_component_name);
+               sprintf(op->dev.bus_id, "%08x", dp->node);
 
        if (of_device_register(op)) {
                printk("%s: Could not register of device.\n",
index 2df25c2b4071e92b7dea55dd32d5e34f4c2413db..35bf895fdeee04bbc1b697e9554060eb2a341625 100644 (file)
@@ -389,12 +389,12 @@ static void __init fill_ebus_device(struct device_node *dp, struct linux_ebus_de
        dev->ofdev.node = dp;
        dev->ofdev.dev.parent = &dev->bus->ofdev.dev;
        dev->ofdev.dev.bus = &ebus_bus_type;
-       strcpy(dev->ofdev.dev.bus_id, dp->path_component_name);
+       sprintf(dev->ofdev.dev.bus_id, "ebus[%08x]", dp->node);
 
        /* Register with core */
        if (of_device_register(&dev->ofdev) != 0)
                printk(KERN_DEBUG "ebus: device registration error for %s!\n",
-                      dev->ofdev.dev.bus_id);
+                      dp->path_component_name);
 
        dp = dp->child;
        if (dp) {
@@ -494,12 +494,12 @@ void __init ebus_init(void)
                ebus->ofdev.node = dp;
                ebus->ofdev.dev.parent = &pdev->dev;
                ebus->ofdev.dev.bus = &ebus_bus_type;
-               strcpy(ebus->ofdev.dev.bus_id, dp->path_component_name);
+               sprintf(ebus->ofdev.dev.bus_id, "ebus%d", num_ebus);
 
                /* Register with core */
                if (of_device_register(&ebus->ofdev) != 0)
                        printk(KERN_DEBUG "ebus: device registration error for %s!\n",
-                              ebus->ofdev.dev.bus_id);
+                              dp->path_component_name);
 
 
                child = dp->child;
index 0f3aec72ef5fc3161530997853502f4d985e5052..f028e68b23f2acf6b6546d63b39f985db3f10ee5 100644 (file)
@@ -115,12 +115,12 @@ static void __init isa_fill_devices(struct sparc_isa_bridge *isa_br)
                isa_dev->ofdev.node = dp;
                isa_dev->ofdev.dev.parent = &isa_br->ofdev.dev;
                isa_dev->ofdev.dev.bus = &isa_bus_type;
-               strcpy(isa_dev->ofdev.dev.bus_id, dp->path_component_name);
+               sprintf(isa_dev->ofdev.dev.bus_id, "isa[%08x]", dp->node);
 
                /* Register with core */
                if (of_device_register(&isa_dev->ofdev) != 0) {
                        printk(KERN_DEBUG "isa: device registration error for %s!\n",
-                              isa_dev->ofdev.dev.bus_id);
+                              dp->path_component_name);
                        kfree(isa_dev);
                        goto next_sibling;
                }
@@ -191,12 +191,12 @@ void __init isa_init(void)
                isa_br->ofdev.node = dp;
                isa_br->ofdev.dev.parent = &pdev->dev;
                isa_br->ofdev.dev.bus = &isa_bus_type;
-               strcpy(isa_br->ofdev.dev.bus_id, dp->path_component_name);
+               sprintf(isa_br->ofdev.dev.bus_id, "isa%d", index);
 
                /* Register with core */
                if (of_device_register(&isa_br->ofdev) != 0) {
                        printk(KERN_DEBUG "isa: device registration error for %s!\n",
-                              isa_br->ofdev.dev.bus_id);
+                              dp->path_component_name);
                        kfree(isa_br);
                        return;
                }
index 983ca5f485cfe34ad0e2c78b7dfcc9d6740043f7..8cc14fc6b6f13ff028489260c1e8aa155c791019 100644 (file)
@@ -861,7 +861,7 @@ static struct of_device * __init scan_one_device(struct device_node *dp,
        if (!parent)
                strcpy(op->dev.bus_id, "root");
        else
-               sprintf(op->dev.bus_id, "%s@%08x", dp->name, dp->node);
+               sprintf(op->dev.bus_id, "%08x", dp->node);
 
        if (of_device_register(op)) {
                printk("%s: Could not register of device.\n",
index 935952ef88f19d04127a560a2b2942d5a54c9c56..98fcbb3d5560bad9463109915e64f75222558853 100644 (file)
@@ -61,11 +61,11 @@ static void __init fill_sbus_device(struct device_node *dp, struct sbus_dev *sde
        else
                sdev->ofdev.dev.parent = &sdev->bus->ofdev.dev;
        sdev->ofdev.dev.bus = &sbus_bus_type;
-       strcpy(sdev->ofdev.dev.bus_id, dp->path_component_name);
+       sprintf(sdev->ofdev.dev.bus_id, "sbus[%08x]", dp->node);
 
        if (of_device_register(&sdev->ofdev) != 0)
                printk(KERN_DEBUG "sbus: device registration error for %s!\n",
-                      sdev->ofdev.dev.bus_id);
+                      dp->path_component_name);
 }
 
 static void __init sbus_bus_ranges_init(struct device_node *dp, struct sbus_bus *sbus)