From: Alexander Lobakin <aleksander.lobakin@intel.com>
To: Justin Stitt <justinstitt@google.com>
Cc: Andrew Lunn <andrew@lunn.ch>,
Florian Fainelli <f.fainelli@gmail.com>,
Vladimir Oltean <olteanv@gmail.com>,
"David S. Miller" <davem@davemloft.net>,
Eric Dumazet <edumazet@google.com>,
Jakub Kicinski <kuba@kernel.org>,
"Paolo Abeni" <pabeni@redhat.com>, <netdev@vger.kernel.org>,
<linux-kernel@vger.kernel.org>, <linux-hardening@vger.kernel.org>,
Kees Cook <keescook@chromium.org>
Subject: Re: [PATCH v2] net: dsa: lan9303: use ethtool_sprintf() for lan9303_get_strings()
Date: Fri, 6 Oct 2023 11:37:40 +0200 [thread overview]
Message-ID: <2bd3fad0-a109-838e-a495-f0ac27286c04@intel.com> (raw)
In-Reply-To: <20231005-strncpy-drivers-net-dsa-lan9303-core-c-v2-1-feb452a532db@google.com>
From: Justin Stitt <justinstitt@google.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@intel.com>
>
>
> ---
> base-commit: cbf3a2cb156a2c911d8f38d8247814b4c07f49a2
> change-id: 20231005-strncpy-drivers-net-dsa-lan9303-core-c-6386858e5c22
>
> Best regards,
> --
> Justin Stitt <justinstitt@google.com>
>
Thanks,
Olek
next prev parent reply other threads:[~2023-10-06 9:38 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-10-05 18:56 [PATCH v2] net: dsa: lan9303: use ethtool_sprintf() for lan9303_get_strings() Justin Stitt
2023-10-05 22:42 ` Kees Cook
2023-10-06 9:37 ` Alexander Lobakin [this message]
2023-11-30 21:59 ` Kees Cook
2023-12-01 6:40 ` Jakub Kicinski
2023-12-01 18:19 ` Kees Cook
2023-12-07 19:51 ` Justin Stitt
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=2bd3fad0-a109-838e-a495-f0ac27286c04@intel.com \
--to=aleksander.lobakin@intel.com \
--cc=andrew@lunn.ch \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=f.fainelli@gmail.com \
--cc=justinstitt@google.com \
--cc=keescook@chromium.org \
--cc=kuba@kernel.org \
--cc=linux-hardening@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=olteanv@gmail.com \
--cc=pabeni@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox