summaryrefslogtreecommitdiffstats
path: root/net/sunrpc
diff options
context:
space:
mode:
authorFedor Tokarev <ftokarev@gmail.com>2020-10-15 16:59:08 +0300
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2020-12-30 11:51:16 +0100
commitcbb0a57326b8ab428e48c509b0bd1f5efb28fe92 (patch)
tree9be73a3d827fb401f24d221144e10bda483c6f32 /net/sunrpc
parenta0842124422eb4e33d1d80cb05cb10875652ac96 (diff)
downloadlinux-stable-cbb0a57326b8ab428e48c509b0bd1f5efb28fe92.tar.gz
linux-stable-cbb0a57326b8ab428e48c509b0bd1f5efb28fe92.tar.bz2
linux-stable-cbb0a57326b8ab428e48c509b0bd1f5efb28fe92.zip
net: sunrpc: Fix 'snprintf' return value check in 'do_xprt_debugfs'
[ Upstream commit 35a6d396721e28ba161595b0fc9e8896c00399bb ] 'snprintf' returns the number of characters which would have been written if enough space had been available, excluding the terminating null byte. Thus, the return value of 'sizeof(buf)' means that the last character has been dropped. Signed-off-by: Fedor Tokarev <ftokarev@gmail.com> Fixes: 2f34b8bfae19 ("SUNRPC: add links for all client xprts to debugfs") Signed-off-by: Trond Myklebust <trond.myklebust@hammerspace.com> Signed-off-by: Sasha Levin <sashal@kernel.org>
Diffstat (limited to 'net/sunrpc')
-rw-r--r--net/sunrpc/debugfs.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/net/sunrpc/debugfs.c b/net/sunrpc/debugfs.c
index fd9bca242724..56029e3af6ff 100644
--- a/net/sunrpc/debugfs.c
+++ b/net/sunrpc/debugfs.c
@@ -128,13 +128,13 @@ static int do_xprt_debugfs(struct rpc_clnt *clnt, struct rpc_xprt *xprt, void *n
return 0;
len = snprintf(name, sizeof(name), "../../rpc_xprt/%s",
xprt->debugfs->d_name.name);
- if (len > sizeof(name))
+ if (len >= sizeof(name))
return -1;
if (*nump == 0)
strcpy(link, "xprt");
else {
len = snprintf(link, sizeof(link), "xprt%d", *nump);
- if (len > sizeof(link))
+ if (len >= sizeof(link))
return -1;
}
debugfs_create_symlink(link, clnt->cl_debugfs, name);