Commit f5ef9d11fd255b30b455d18f8d721bc44cd1296b
1 parent
e803915000
[SPARC]: Fix bus_id[] string overflow.
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>
Showing 6 changed files with 16 additions and 16 deletions Side-by-side Diff
arch/sparc/kernel/ebus.c
... | ... | @@ -237,12 +237,12 @@ |
237 | 237 | dev->ofdev.node = dp; |
238 | 238 | dev->ofdev.dev.parent = &dev->bus->ofdev.dev; |
239 | 239 | dev->ofdev.dev.bus = &ebus_bus_type; |
240 | - strcpy(dev->ofdev.dev.bus_id, dp->path_component_name); | |
240 | + sprintf(dev->ofdev.dev.bus_id, "ebus[%08x]", dp->node); | |
241 | 241 | |
242 | 242 | /* Register with core */ |
243 | 243 | if (of_device_register(&dev->ofdev) != 0) |
244 | 244 | printk(KERN_DEBUG "ebus: device registration error for %s!\n", |
245 | - dev->ofdev.dev.bus_id); | |
245 | + dp->path_component_name); | |
246 | 246 | |
247 | 247 | if ((dp = dp->child) != NULL) { |
248 | 248 | dev->children = (struct linux_ebus_child *) |
249 | 249 | |
... | ... | @@ -332,12 +332,12 @@ |
332 | 332 | ebus->ofdev.node = dp; |
333 | 333 | ebus->ofdev.dev.parent = &pdev->dev; |
334 | 334 | ebus->ofdev.dev.bus = &ebus_bus_type; |
335 | - strcpy(ebus->ofdev.dev.bus_id, dp->path_component_name); | |
335 | + sprintf(ebus->ofdev.dev.bus_id, "ebus%d", num_ebus); | |
336 | 336 | |
337 | 337 | /* Register with core */ |
338 | 338 | if (of_device_register(&ebus->ofdev) != 0) |
339 | 339 | printk(KERN_DEBUG "ebus: device registration error for %s!\n", |
340 | - ebus->ofdev.dev.bus_id); | |
340 | + dp->path_component_name); | |
341 | 341 | |
342 | 342 | |
343 | 343 | nd = dp->child; |
arch/sparc/kernel/of_device.c
... | ... | @@ -651,7 +651,7 @@ |
651 | 651 | if (!parent) |
652 | 652 | strcpy(op->dev.bus_id, "root"); |
653 | 653 | else |
654 | - strcpy(op->dev.bus_id, dp->path_component_name); | |
654 | + sprintf(op->dev.bus_id, "%08x", dp->node); | |
655 | 655 | |
656 | 656 | if (of_device_register(op)) { |
657 | 657 | printk("%s: Could not register of device.\n", |
arch/sparc64/kernel/ebus.c
... | ... | @@ -389,12 +389,12 @@ |
389 | 389 | dev->ofdev.node = dp; |
390 | 390 | dev->ofdev.dev.parent = &dev->bus->ofdev.dev; |
391 | 391 | dev->ofdev.dev.bus = &ebus_bus_type; |
392 | - strcpy(dev->ofdev.dev.bus_id, dp->path_component_name); | |
392 | + sprintf(dev->ofdev.dev.bus_id, "ebus[%08x]", dp->node); | |
393 | 393 | |
394 | 394 | /* Register with core */ |
395 | 395 | if (of_device_register(&dev->ofdev) != 0) |
396 | 396 | printk(KERN_DEBUG "ebus: device registration error for %s!\n", |
397 | - dev->ofdev.dev.bus_id); | |
397 | + dp->path_component_name); | |
398 | 398 | |
399 | 399 | dp = dp->child; |
400 | 400 | if (dp) { |
401 | 401 | |
... | ... | @@ -494,12 +494,12 @@ |
494 | 494 | ebus->ofdev.node = dp; |
495 | 495 | ebus->ofdev.dev.parent = &pdev->dev; |
496 | 496 | ebus->ofdev.dev.bus = &ebus_bus_type; |
497 | - strcpy(ebus->ofdev.dev.bus_id, dp->path_component_name); | |
497 | + sprintf(ebus->ofdev.dev.bus_id, "ebus%d", num_ebus); | |
498 | 498 | |
499 | 499 | /* Register with core */ |
500 | 500 | if (of_device_register(&ebus->ofdev) != 0) |
501 | 501 | printk(KERN_DEBUG "ebus: device registration error for %s!\n", |
502 | - ebus->ofdev.dev.bus_id); | |
502 | + dp->path_component_name); | |
503 | 503 | |
504 | 504 | |
505 | 505 | child = dp->child; |
arch/sparc64/kernel/isa.c
... | ... | @@ -115,12 +115,12 @@ |
115 | 115 | isa_dev->ofdev.node = dp; |
116 | 116 | isa_dev->ofdev.dev.parent = &isa_br->ofdev.dev; |
117 | 117 | isa_dev->ofdev.dev.bus = &isa_bus_type; |
118 | - strcpy(isa_dev->ofdev.dev.bus_id, dp->path_component_name); | |
118 | + sprintf(isa_dev->ofdev.dev.bus_id, "isa[%08x]", dp->node); | |
119 | 119 | |
120 | 120 | /* Register with core */ |
121 | 121 | if (of_device_register(&isa_dev->ofdev) != 0) { |
122 | 122 | printk(KERN_DEBUG "isa: device registration error for %s!\n", |
123 | - isa_dev->ofdev.dev.bus_id); | |
123 | + dp->path_component_name); | |
124 | 124 | kfree(isa_dev); |
125 | 125 | goto next_sibling; |
126 | 126 | } |
127 | 127 | |
... | ... | @@ -191,12 +191,12 @@ |
191 | 191 | isa_br->ofdev.node = dp; |
192 | 192 | isa_br->ofdev.dev.parent = &pdev->dev; |
193 | 193 | isa_br->ofdev.dev.bus = &isa_bus_type; |
194 | - strcpy(isa_br->ofdev.dev.bus_id, dp->path_component_name); | |
194 | + sprintf(isa_br->ofdev.dev.bus_id, "isa%d", index); | |
195 | 195 | |
196 | 196 | /* Register with core */ |
197 | 197 | if (of_device_register(&isa_br->ofdev) != 0) { |
198 | 198 | printk(KERN_DEBUG "isa: device registration error for %s!\n", |
199 | - isa_br->ofdev.dev.bus_id); | |
199 | + dp->path_component_name); | |
200 | 200 | kfree(isa_br); |
201 | 201 | return; |
202 | 202 | } |
arch/sparc64/kernel/of_device.c
... | ... | @@ -861,7 +861,7 @@ |
861 | 861 | if (!parent) |
862 | 862 | strcpy(op->dev.bus_id, "root"); |
863 | 863 | else |
864 | - sprintf(op->dev.bus_id, "%s@%08x", dp->name, dp->node); | |
864 | + sprintf(op->dev.bus_id, "%08x", dp->node); | |
865 | 865 | |
866 | 866 | if (of_device_register(op)) { |
867 | 867 | printk("%s: Could not register of device.\n", |
drivers/sbus/sbus.c
... | ... | @@ -61,11 +61,11 @@ |
61 | 61 | else |
62 | 62 | sdev->ofdev.dev.parent = &sdev->bus->ofdev.dev; |
63 | 63 | sdev->ofdev.dev.bus = &sbus_bus_type; |
64 | - strcpy(sdev->ofdev.dev.bus_id, dp->path_component_name); | |
64 | + sprintf(sdev->ofdev.dev.bus_id, "sbus[%08x]", dp->node); | |
65 | 65 | |
66 | 66 | if (of_device_register(&sdev->ofdev) != 0) |
67 | 67 | printk(KERN_DEBUG "sbus: device registration error for %s!\n", |
68 | - sdev->ofdev.dev.bus_id); | |
68 | + dp->path_component_name); | |
69 | 69 | } |
70 | 70 | |
71 | 71 | static void __init sbus_bus_ranges_init(struct device_node *dp, struct sbus_bus *sbus) |