Received: by 10.223.185.116 with SMTP id b49csp5443007wrg; Wed, 7 Mar 2018 11:50:51 -0800 (PST) X-Google-Smtp-Source: AG47ELvyewpa3ihE9JIZY1cVkGZePUJWIklqX7k+gzpD+s4V+lRCVIRXucDEYK0iT+WpfINMNUQf X-Received: by 10.101.97.207 with SMTP id j15mr18750008pgv.266.1520452251377; Wed, 07 Mar 2018 11:50:51 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1520452251; cv=none; d=google.com; s=arc-20160816; b=rd4uOytGRNicOMpoo4o3zhuU9U6KZHpndYXTUc1vnR0VBKOFv9H5ioaJburPPT72H9 jWok+oH3YV3OL2sgtjAwRRwyfAEjteXyQYu7f+xD6V5g2UzFgDvuZNFtmFFFmWAYSAWg rDiC7xeE3z2JzWjRpWJMAd29W6Qp3xN09z0d2ifPkDLQ0kPntksj/1T27aTvI+CPiYm3 CWtbeRpHNrC4AMLiEihy4mfJorofIAcLLFYqRf3CBN7UQqbM0x1Iv01yPEM8aVO5701c J63peaDSFpbVF21QilHPs7cQMYLt4tP5sh5os2JNHR3dQh8wo+2Qwdd8XF+dlRiP6gqw hAYQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=N0cwCstZ1sFb0FXynx+f83TVHlS9KM98WN+gFA/N1l8=; b=kWjzAfs72vsuEwbwk8X7u8FXssufhFR2VfSmCddO3CsYMtMbIt/Gk9LoxM2Fgfxc1l 64AYJAbYinV07+la+dMxBs2HVM77mObEYIechpOpcFlMDKLI6RdW7cZ8QElCt4YeNi8o xBF9CCfdhp5eJ8+g+aI+I61qacX2yfIW4HLc1GnqKkhqPVa9V/ze2YVMkincqevSdfCg 1Om9SP/iIDse3ncsFv6svf9Etxpywiqgn0W9evb9e/USpksFSb71ziAgytmzDoq0HitB 85c3IOEQubuXBsomiLkNNmotjB4KxX8rQIp8Ai6RzGjt9gNZbtZxiEpMLPLzkY6GvLi4 DRMw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-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 u86si14228499pfa.69.2018.03.07.11.50.36; Wed, 07 Mar 2018 11:50:51 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-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 linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S965958AbeCGTs2 (ORCPT + 99 others); Wed, 7 Mar 2018 14:48:28 -0500 Received: from mail.linuxfoundation.org ([140.211.169.12]:45420 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S965910AbeCGTsU (ORCPT ); Wed, 7 Mar 2018 14:48:20 -0500 Received: from localhost (unknown [185.236.200.248]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id 1CCB510DE; Wed, 7 Mar 2018 19:48:20 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Andrew Lunn , Arnd Bergmann Subject: [PATCH 4.14 092/110] ARM: orion: fix orion_ge00_switch_board_info initialization Date: Wed, 7 Mar 2018 11:39:15 -0800 Message-Id: <20180307191051.632195007@linuxfoundation.org> X-Mailer: git-send-email 2.16.2 In-Reply-To: <20180307191039.748351103@linuxfoundation.org> References: <20180307191039.748351103@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.14-stable review patch. If anyone has any objections, please let me know. ------------------ From: Arnd Bergmann commit 8337d083507b9827dfb36d545538b7789df834fd upstream. 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 Signed-off-by: Arnd Bergmann Signed-off-by: Greg Kroah-Hartman --- arch/arm/plat-orion/common.c | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) --- a/arch/arm/plat-orion/common.c +++ b/arch/arm/plat-orion/common.c @@ -472,28 +472,27 @@ void __init orion_ge11_init(struct mv643 /***************************************************************************** * 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); }