Skip to content

Commit 7941ee4

Browse files
ftokarevgregkh
authored andcommitted
net: sunrpc: Fix 'snprintf' return value check in 'do_xprt_debugfs'
[ Upstream commit 35a6d39 ] '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: 2f34b8b ("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>
1 parent 77303b6 commit 7941ee4

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

‎net/sunrpc/debugfs.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -128,13 +128,13 @@ static int do_xprt_debugfs(struct rpc_clnt *clnt, struct rpc_xprt *xprt, void *n
128128
return 0;
129129
len = snprintf(name, sizeof(name), "../../rpc_xprt/%s",
130130
xprt->debugfs->d_name.name);
131-
if (len > sizeof(name))
131+
if (len >= sizeof(name))
132132
return -1;
133133
if (*nump == 0)
134134
strcpy(link, "xprt");
135135
else {
136136
len = snprintf(link, sizeof(link), "xprt%d", *nump);
137-
if (len > sizeof(link))
137+
if (len >= sizeof(link))
138138
return -1;
139139
}
140140
debugfs_create_symlink(link, clnt->cl_debugfs, name);

0 commit comments

Comments
 (0)