[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <2bd3fad0-a109-838e-a495-f0ac27286c04@intel.com>
Date: Fri, 6 Oct 2023 11:37:40 +0200
From: Alexander Lobakin <aleksander.lobakin@...el.com>
To: Justin Stitt <justinstitt@...gle.com>
CC: Andrew Lunn <andrew@...n.ch>,
Florian Fainelli <f.fainelli@...il.com>,
Vladimir Oltean <olteanv@...il.com>,
"David S. Miller" <davem@...emloft.net>,
Eric Dumazet <edumazet@...gle.com>,
Jakub Kicinski <kuba@...nel.org>,
"Paolo Abeni" <pabeni@...hat.com>, <netdev@...r.kernel.org>,
<linux-kernel@...r.kernel.org>, <linux-hardening@...r.kernel.org>,
Kees Cook <keescook@...omium.org>
Subject: Re: [PATCH v2] net: dsa: lan9303: use ethtool_sprintf() for
lan9303_get_strings()
From: Justin Stitt <justinstitt@...gle.com>
Date: Thu, 05 Oct 2023 18:56:50 +0000
> This pattern of strncpy with some pointer arithmetic setting fixed-sized
> intervals with string literal data is a bit weird so let's use
> ethtool_sprintf() as this has more obvious behavior and is less-error
> prone.
[...]
> diff --git a/drivers/net/dsa/lan9303-core.c b/drivers/net/dsa/lan9303-core.c
> index ee67adeb2cdb..95a8e5168c2a 100644
> --- a/drivers/net/dsa/lan9303-core.c
> +++ b/drivers/net/dsa/lan9303-core.c
> @@ -1007,14 +1007,14 @@ static const struct lan9303_mib_desc lan9303_mib[] = {
> static void lan9303_get_strings(struct dsa_switch *ds, int port,
> u32 stringset, uint8_t *data)
> {
> + u8 *buf = data;
Is it needed here? I thought you could pass @data directly to
ethtool_sprintf(), if it doesn't mind.
> unsigned int u;
>
> if (stringset != ETH_SS_STATS)
> return;
>
> for (u = 0; u < ARRAY_SIZE(lan9303_mib); u++) {
> - strncpy(data + u * ETH_GSTRING_LEN, lan9303_mib[u].name,
> - ETH_GSTRING_LEN);
> + ethtool_sprintf(&buf, "%s", lan9303_mib[u].name);
> }
> }
Either way, this was a nitpick, so
Reviewed-by: Alexander Lobakin <aleksander.lobakin@...el.com>
>
>
> ---
> base-commit: cbf3a2cb156a2c911d8f38d8247814b4c07f49a2
> change-id: 20231005-strncpy-drivers-net-dsa-lan9303-core-c-6386858e5c22
>
> Best regards,
> --
> Justin Stitt <justinstitt@...gle.com>
>
Thanks,
Olek
Powered by blists - more mailing lists