Commit 35a6d396 authored by Fedor Tokarev's avatar Fedor Tokarev Committed by Trond Myklebust

net: sunrpc: Fix 'snprintf' return value check in 'do_xprt_debugfs'

'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: default avatarFedor Tokarev <ftokarev@gmail.com>
Fixes: 2f34b8bf ("SUNRPC: add links for all client xprts to debugfs")
Signed-off-by: default avatarTrond Myklebust <trond.myklebust@hammerspace.com>
parent d3ff46fe
...@@ -128,13 +128,13 @@ static int do_xprt_debugfs(struct rpc_clnt *clnt, struct rpc_xprt *xprt, void *n ...@@ -128,13 +128,13 @@ static int do_xprt_debugfs(struct rpc_clnt *clnt, struct rpc_xprt *xprt, void *n
return 0; return 0;
len = snprintf(name, sizeof(name), "../../rpc_xprt/%s", len = snprintf(name, sizeof(name), "../../rpc_xprt/%s",
xprt->debugfs->d_name.name); xprt->debugfs->d_name.name);
if (len > sizeof(name)) if (len >= sizeof(name))
return -1; return -1;
if (*nump == 0) if (*nump == 0)
strcpy(link, "xprt"); strcpy(link, "xprt");
else { else {
len = snprintf(link, sizeof(link), "xprt%d", *nump); len = snprintf(link, sizeof(link), "xprt%d", *nump);
if (len > sizeof(link)) if (len >= sizeof(link))
return -1; return -1;
} }
debugfs_create_symlink(link, clnt->cl_debugfs, name); debugfs_create_symlink(link, clnt->cl_debugfs, name);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment