From patchwork Wed Feb 21 12:18:49 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 129052 Delivered-To: patch@linaro.org Received: by 10.46.124.24 with SMTP id x24csp557595ljc; Wed, 21 Feb 2018 04:19:26 -0800 (PST) X-Google-Smtp-Source: AH8x225R+PQakFc4QE5/0mmqdjKIR5VElH+YJlrg91ImWDjokc4GmN+HxGKJSaSrqOYgnGoBYAb3 X-Received: by 10.99.125.16 with SMTP id y16mr2559029pgc.3.1519215566337; Wed, 21 Feb 2018 04:19:26 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519215566; cv=none; d=google.com; s=arc-20160816; b=ffkxn4Kxi5S1UmHApp7ufdBG939YKTBvGJJhg6WwrE/yadrpAKTGKAoGlfpLSWSUpI qBUw7nSBA3+n2KipZT676aYf3FsS10LEPQhU51E59BN7SEBtn4GRohN6xW1FdcO0sMBh iMWAGuToCIWyjAxLKAEAsjIqZ1TpAb4lvf3BDXCHHqAG0gRd6Wqmhk1zdLv3MTvtL+Gz Qm6BZ+PJzcbQagTHQEDg6wqaDYjq2wwCyzkiodh078qX+9WoDgivfAR9+qewQ9p7s7Jt 2dHLeXjcLZowbjS5zUlRfQXgWrEJOdSvTTLjI7GicH1M51hmoI/WqSPpxylT1E0HLRO/ Cd7Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :arc-authentication-results; bh=L2gVYueJaCwQNjImt0QfOwTjTF7OFs/MFfOR9OnhYIw=; b=G2Vewj945p1EigrKV8OOedUKxhL+PD7GdzgmnrGHnl0OnXBjDVgP9YnjEnfcTtDpEc MXKITGRojBMaI5/medBEsrT40WevQvXr969V5afjDUBeClsxiSApc7XblVdfp6TBUVsX M5nCR9th2JPiFY4knPlYpf+wX1f3/6mte7QsYe+ocpRBVW3Ebe1CyKZBJQBWQqciUkx7 hKh0GNSaSsdiHll2eIp8yYgYq9aEyQ2PBO39+fgykqdi8Q6JsdwmORMqltvRu8uuR+6M WIRnE7StyBJQBfpl63VnuDbIhFOTAvZM+ocmuTEwM69M5UQjP9w20NPr+gU0PMO1Bhij ZXtA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of stable-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=stable-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id g3-v6si1163883plp.38.2018.02.21.04.19.26; Wed, 21 Feb 2018 04:19:26 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of stable-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of stable-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=stable-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752044AbeBUMTZ (ORCPT + 10 others); Wed, 21 Feb 2018 07:19:25 -0500 Received: from mout.kundenserver.de ([217.72.192.75]:55289 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751639AbeBUMTY (ORCPT ); Wed, 21 Feb 2018 07:19:24 -0500 Received: from wuerfel.lan ([95.208.111.237]) by mrelayeu.kundenserver.de (mreue104 [212.227.15.145]) with ESMTPA (Nemesis) id 0M0iAY-1eUCej43vK-00unei; Wed, 21 Feb 2018 13:19:00 +0100 From: Arnd Bergmann To: Jason Cooper , Andrew Lunn , Sebastian Hesselbarth , Gregory Clement Cc: Arnd Bergmann , stable@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH] ARM: orion: fix orion_ge00_switch_board_info initialization Date: Wed, 21 Feb 2018 13:18:49 +0100 Message-Id: <20180221121856.3241260-1-arnd@ar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xPbGNVFyCNDkordZL8cXPEasl6V94H9HA== Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org 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 Signed-off-by: Arnd Bergmann --- v2: complete rewrite --- arch/arm/plat-orion/common.c | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) -- 2.9.0 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, /***************************************************************************** * Ethernet switch ****************************************************************************/ -static __initconst const char *orion_ge00_mvmdio_bus_name = "orion-mii"; -static __initdata struct mdio_board_info - orion_ge00_switch_board_info; +static __initdata struct mdio_board_info orion_ge00_switch_board_info = { + .bus_id = "orion-mii", + .modalias = "mv88e6085", +}; void __init orion_ge00_switch_init(struct dsa_chip_data *d) { - struct mdio_board_info *bd; unsigned int i; if (!IS_BUILTIN(CONFIG_PHYLIB)) return; - for (i = 0; i < ARRAY_SIZE(d->port_names); i++) - if (!strcmp(d->port_names[i], "cpu")) + for (i = 0; i < ARRAY_SIZE(d->port_names); i++) { + if (!strcmp(d->port_names[i], "cpu")) { + d->netdev[i] = &orion_ge00.dev; break; + } + } - bd = &orion_ge00_switch_board_info; - bd->bus_id = orion_ge00_mvmdio_bus_name; - bd->mdio_addr = d->sw_addr; - d->netdev[i] = &orion_ge00.dev; - strcpy(bd->modalias, "mv88e6085"); - bd->platform_data = d; + orion_ge00_switch_board_info.mdio_addr = d->sw_addr; + orion_ge00_switch_board_info.platform_data = d; mdiobus_register_board_info(&orion_ge00_switch_board_info, 1); }