aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorArnd Bergmann <arnd@arndb.de>2018-02-21 07:18:49 -0500
committerArnd Bergmann <arnd@arndb.de>2018-02-22 11:48:39 -0500
commit8337d083507b9827dfb36d545538b7789df834fd (patch)
treed2d23262f66ab864221e2980d686c4f542ec8fc8
parente6d210180aec2ff4f318a0b22b8963c3c7e45c03 (diff)
ARM: orion: fix orion_ge00_switch_board_info initialization
A section type mismatch warning shows up when building with LTO, since orion_ge00_mvmdio_bus_name was put in __initconst but not marked const itself: include/linux/of.h: In function 'spear_setup_of_timer': arch/arm/mach-spear/time.c:207:34: error: 'timer_of_match' causes a section type conflict with 'orion_ge00_mvmdio_bus_name' static const struct of_device_id timer_of_match[] __initconst = { ^ arch/arm/plat-orion/common.c:475:32: note: 'orion_ge00_mvmdio_bus_name' was declared here static __initconst const char *orion_ge00_mvmdio_bus_name = "orion-mii"; ^ As pointed out by Andrew Lunn, it should in fact be 'const' but not '__initconst' because the string is never copied but may be accessed after the init sections are freed. To fix that, I get rid of the extra symbol and rewrite the initialization in a simpler way that assigns both the bus_id and modalias statically. I spotted another theoretical bug in the same place, where d->netdev[i] may be an out of bounds access, this can be fixed by moving the device assignment into the loop. Cc: stable@vger.kernel.org Reviewed-by: Andrew Lunn <andrew@lunn.ch> Signed-off-by: Arnd Bergmann <arnd@arndb.de>
-rw-r--r--arch/arm/plat-orion/common.c23
1 files changed, 11 insertions, 12 deletions
diff --git a/arch/arm/plat-orion/common.c b/arch/arm/plat-orion/common.c
index aff6994950ba..a2399fd66e97 100644
--- a/arch/arm/plat-orion/common.c
+++ b/arch/arm/plat-orion/common.c
@@ -472,28 +472,27 @@ void __init orion_ge11_init(struct mv643xx_eth_platform_data *eth_data,
472/***************************************************************************** 472/*****************************************************************************
473 * Ethernet switch 473 * Ethernet switch
474 ****************************************************************************/ 474 ****************************************************************************/
475static __initconst const char *orion_ge00_mvmdio_bus_name = "orion-mii"; 475static __initdata struct mdio_board_info orion_ge00_switch_board_info = {
476static __initdata struct mdio_board_info 476 .bus_id = "orion-mii",
477 orion_ge00_switch_board_info; 477 .modalias = "mv88e6085",
478};
478 479
479void __init orion_ge00_switch_init(struct dsa_chip_data *d) 480void __init orion_ge00_switch_init(struct dsa_chip_data *d)
480{ 481{
481 struct mdio_board_info *bd;
482 unsigned int i; 482 unsigned int i;
483 483
484 if (!IS_BUILTIN(CONFIG_PHYLIB)) 484 if (!IS_BUILTIN(CONFIG_PHYLIB))
485 return; 485 return;
486 486
487 for (i = 0; i < ARRAY_SIZE(d->port_names); i++) 487 for (i = 0; i < ARRAY_SIZE(d->port_names); i++) {
488 if (!strcmp(d->port_names[i], "cpu")) 488 if (!strcmp(d->port_names[i], "cpu")) {
489 d->netdev[i] = &orion_ge00.dev;
489 break; 490 break;
491 }
492 }
490 493
491 bd = &orion_ge00_switch_board_info; 494 orion_ge00_switch_board_info.mdio_addr = d->sw_addr;
492 bd->bus_id = orion_ge00_mvmdio_bus_name; 495 orion_ge00_switch_board_info.platform_data = d;
493 bd->mdio_addr = d->sw_addr;
494 d->netdev[i] = &orion_ge00.dev;
495 strcpy(bd->modalias, "mv88e6085");
496 bd->platform_data = d;
497 496
498 mdiobus_register_board_info(&orion_ge00_switch_board_info, 1); 497 mdiobus_register_board_info(&orion_ge00_switch_board_info, 1);
499} 498}