Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp1992858pxj; Sun, 13 Jun 2021 05:22:42 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz98W91TyFdYalqBtYA1h9N+HCZk0w3fRsZg3hvqXhYRiWcGK/l3BzU6ncVumluBmklVTr1 X-Received: by 2002:aa7:cb5a:: with SMTP id w26mr12863532edt.139.1623586961977; Sun, 13 Jun 2021 05:22:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1623586961; cv=none; d=google.com; s=arc-20160816; b=B4jKtrxQDoLAr/NDRfUk7EyNNjD1W2lzorYmNZCHu3PTnr+KtniTltBF72/oJq+BhH ruwS3RMCultutj9sSC/Gt1fCQQUa7l9ubtExa2dZbtH1VIbqP+UWKQcZL6uT2QX4iGwC TZ5tJ4Rt87FrUF+6Ly0KoLkgacoBJ3iU4zU+RcjH2vaQFfkfeZq51M5TmNE9Cc5xhBMi xJfIpatPZ1ltbqlipmKhj/YQPrVAWI/KIL/lmKYpsyKHAo1DUPSbTP+5KC/L4YGmnwmn Tesq2oWNJKIyWXQwa0G6PJjKq5v/VzacHWpwEvqSMgaS/A8fEsDgswgeqAPY2sGcIpIp NwUA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=mmyFe4CD1HqfyTgZipLbaHYfBnHjTeV2soAr4WgrLn0=; b=jQghMNOkj/9waK4FDGXcLid8lrla2vvZDYTBwhBzP7zCpRjs2SnaBsGLnRemFH91rg eYemezAQESTuibo/0Ay/dyo2yoj/lr1XE+MfVFO4V9jhNNQu5v1LgbrGHVXsGErfyhpL 5rWNwri3lazMCvGmwwhhpkwFzFwqpBjC3lYhea/4c6fcKyMAKfYYzRWa2q29wCR7wHZC YCKnj8gq5Li96/4gPrsUSabV5TGu4peIhZNKL/wn24QydZ02ePDkD/ti3qoOpqidtbZ8 uVdfmlSu5UW0sCGuba4sBgqH3wyUeWXAoUCKAsyKesY5U4pCzHPiallk/cTnld9BajGZ payw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail (test mode) header.i=@armlinux.org.uk header.s=pandora-2019 header.b=Jcam4PNy; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=armlinux.org.uk Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id j12si2920310ejj.20.2021.06.13.05.22.16; Sun, 13 Jun 2021 05:22:41 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=fail (test mode) header.i=@armlinux.org.uk header.s=pandora-2019 header.b=Jcam4PNy; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=armlinux.org.uk Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231761AbhFMMWz (ORCPT + 99 others); Sun, 13 Jun 2021 08:22:55 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55978 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231738AbhFMMWy (ORCPT ); Sun, 13 Jun 2021 08:22:54 -0400 Received: from pandora.armlinux.org.uk (pandora.armlinux.org.uk [IPv6:2001:4d48:ad52:32c8:5054:ff:fe00:142]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4EF84C061574; Sun, 13 Jun 2021 05:20:53 -0700 (PDT) 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-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210613115820.1525478-2-code@reto-schneider.ch> User-Agent: Mutt/1.10.1 (2018-07-13) Sender: Russell King (Oracle) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.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!