From: Alejandro Lucero <alejandro.lucero@netronome.com>
To: stable@dpdk.org
Cc: yskoh@mellanox.com
Subject: [dpdk-stable] [PATH 17.11] net/nfp: fix misuse of strlcpy
Date: Fri, 15 Feb 2019 10:30:44 +0000 [thread overview]
Message-ID: <20190215103044.10301-1-alejandro.lucero@netronome.com> (raw)
Current strlcpy function is doing the wrong thing and as a consequence
the firmware does not find the symbol requested precluding the right
NFP initialization.
Using strncpy is safe here since the symbol length can never be longer
than the buffer size where the firmware will get the symbol to work
with. However, newer compilers do not allow to have the strncpy using
the source length as the third parameter, so this patch uses instead a
memcpy call with a previous memset for cleaning up the buffer to be
used by the firmware.
Fixes: a5d659c2d03f ("net/nfp: replace strncpy by strlcpy")
Signed-off-by: Alejandro Lucero <alejandro.lucero@netronome.com>
---
drivers/net/nfp/nfp_nspu.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/drivers/net/nfp/nfp_nspu.c b/drivers/net/nfp/nfp_nspu.c
index ac5bce3b1..d4abb6c8e 100644
--- a/drivers/net/nfp/nfp_nspu.c
+++ b/drivers/net/nfp/nfp_nspu.c
@@ -424,7 +424,9 @@ nfp_nspu_set_bar_from_symbl(nspu_desc_t *desc, const char *symbl,
if (!sym_buf)
return -ENOMEM;
- strlcpy(sym_buf, symbl, sizeof(sym_buf));
+ memset(sym_buf, 0, desc->buf_size);
+ memcpy(sym_buf, symbl, strlen(symbl));
+
ret = nspu_command(desc, NSP_CMD_GET_SYMBOL, 1, 1, sym_buf,
NFP_SYM_DESC_LEN, strlen(symbl));
if (ret) {
--
2.17.1
next reply other threads:[~2019-02-15 10:30 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-02-15 10:30 Alejandro Lucero [this message]
2019-02-16 7:49 ` Yongseok Koh
2019-02-20 10:02 ` Alejandro Lucero
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=20190215103044.10301-1-alejandro.lucero@netronome.com \
--to=alejandro.lucero@netronome.com \
--cc=stable@dpdk.org \
--cc=yskoh@mellanox.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;
as well as URLs for NNTP newsgroup(s).