From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-10.4 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_1 autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id CB9F2C48BCF for ; Sun, 13 Jun 2021 12:24:58 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 92E0B611CA for ; Sun, 13 Jun 2021 12:24:58 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 92E0B611CA Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=armlinux.org.uk Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References: Message-ID:Subject:Cc:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=Ull3MM/JbrmBWIaIrZMmqQV7anxtWAhzkvv6jV7TGZM=; b=UWo+7MmV/jQBA/ WdD1HqIXNafLKcB7wLYINdEljsRF4HsdAsv/asHjD0tp+Y0UNtYkdNnejuwm7Jvg67eY++RvSK4fU coaJnAOsPvD7oVT0TAqztoxYatKc4imtOMOiyNYPEhRjkM6IGprBwQmt3Bc2Yiqh33e69OaVuONY3 d0Obflv+lagnVQtaFQxAYrrFDvPQCjCd2nhsRasSGluep0s/L2qv/qBbA+prt6sEqSvGjBKwd6x0L 7MzdXDaLAO7DOoNlKFE6V2qDCVZaixMGmyk5udLKQ2I1HjPlNXBNOXTfQTpv+HaGl2gGLxzVlqY17 b4ggt/fS+4R2wK5LEgdA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1lsP8m-00AQ4F-Fw; Sun, 13 Jun 2021 12:23:00 +0000 Received: from pandora.armlinux.org.uk ([2001:4d48:ad52:32c8:5054:ff:fe00:142]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1lsP8h-00APxT-BN; Sun, 13 Jun 2021 12:22:57 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=armlinux.org.uk; s=pandora-2019; h=Sender:In-Reply-To:Content-Type: MIME-Version:References:Message-ID:Subject:Cc:To:From:Date:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=mmyFe4CD1HqfyTgZipLbaHYfBnHjTeV2soAr4WgrLn0=; b=Jcam4PNyqOrWoyMZeEHGBppGG BjX0jmsrgghgEF+xxiDoIxtfzSsIPtPWurfL4igsI+46/HXriPp/D4Pf20YFn7v0+XNdhq56CjozY J0k/br+tWAkH6oTceb3MwPrS8WnU/5D9Jy27AhtXoWSOWu2jrUfY4Xwa6Zb9KIzKdNlsk50wP46Od +uxthAQoD+TGMKdenzFsJ/lhNhP7XIY+O8eBnhy6H7xx4esZd/gM9L59bTyuUC3aGGvQOHbUJUZXw c/95MON/iYMlZYQUyZ5Sg6qfbw/vYUZP8QomsBWaYS9vSeAd71uT8HH0b1u83lc45YIKaMtIPJgGG wFIl+zBMw==; Received: from shell.armlinux.org.uk ([fd8f:7570:feb6:1:5054:ff:fe00:4ec]:44976) by pandora.armlinux.org.uk with esmtpsa (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1lsP6e-0003N9-DD; Sun, 13 Jun 2021 13:20:48 +0100 Received: from linux by shell.armlinux.org.uk with local (Exim 4.92) (envelope-from ) id 1lsP6Z-0003BA-Cn; Sun, 13 Jun 2021 13:20:43 +0100 Date: Sun, 13 Jun 2021 13:20:43 +0100 From: "Russell King (Oracle)" To: Reto Schneider Cc: devicetree@vger.kernel.org, linux-mediatek@lists.infradead.org, netdev@vger.kernel.org, Stefan Roese , Reto Schneider , "David S. Miller" , Felix Fietkau , Jakub Kicinski , John Crispin , Mark Lee , Matthias Brugger , Sean Wang , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v1 2/2] net: ethernet: mtk_eth_soc: Support custom ifname Message-ID: <20210613122043.GP22278@shell.armlinux.org.uk> References: <20210613115820.1525478-1-code@reto-schneider.ch> <20210613115820.1525478-2-code@reto-schneider.ch> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20210613115820.1525478-2-code@reto-schneider.ch> User-Agent: Mutt/1.10.1 (2018-07-13) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210613_052255_414808_78C28BA4 X-CRM114-Status: GOOD ( 15.61 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Sun, Jun 13, 2021 at 01:58:19PM +0200, Reto Schneider wrote: > diff --git a/drivers/net/ethernet/mediatek/mtk_eth_soc.c b/drivers/net/ethernet/mediatek/mtk_eth_soc.c > index 64adfd24e134..8bb09801918f 100644 > --- a/drivers/net/ethernet/mediatek/mtk_eth_soc.c > +++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.c > @@ -2948,6 +2948,7 @@ static const struct net_device_ops mtk_netdev_ops = { > static int mtk_add_mac(struct mtk_eth *eth, struct device_node *np) > { > const __be32 *_id = of_get_property(np, "reg", NULL); > + const char *const name = of_get_property(np, "label", NULL); > phy_interface_t phy_mode; > struct phylink *phylink; > struct mtk_mac *mac; > @@ -3020,6 +3021,9 @@ static int mtk_add_mac(struct mtk_eth *eth, struct device_node *np) > > mac->phylink = phylink; > > + if (name) > + strncpy(eth->netdev[id]->name, name, IFNAMSIZ); Please don't use strncpy() - this is a good example why strncpy() is bad news. * strncpy - Copy a length-limited, C-string * @dest: Where to copy the string to * @src: Where to copy the string from * @count: The maximum number of bytes to copy * * The result is not %NUL-terminated if the source exceeds * @count bytes. Consequently, if "name" is IFNAMSIZ bytes or longer, eth->netdev[id]->name will not be NUL terminated, and subsequent use will run off the end of the string. strscpy() is safer to use here. Thanks. -- RMK's Patch system: https://www.armlinux.org.uk/developer/patches/ FTTP is here! 40Mbps down 10Mbps up. Decent connectivity at last! _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel