]> git.baikalelectronics.ru Git - kernel.git/commitdiff
net: sunrpc: Fix 'snprintf' return value check in 'do_xprt_debugfs'
authorFedor Tokarev <ftokarev@gmail.com>
Thu, 15 Oct 2020 13:59:08 +0000 (16:59 +0300)
committerTrond Myklebust <trond.myklebust@hammerspace.com>
Wed, 2 Dec 2020 19:05:54 +0000 (14:05 -0500)
'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: 7f383e867afb ("SUNRPC: add links for all client xprts to debugfs")
Signed-off-by: Trond Myklebust <trond.myklebust@hammerspace.com>
net/sunrpc/debugfs.c

index fd9bca2427242760e4fd261c988c4e546723896e..56029e3af6ff0b29271129d2c5d409027ab4d5d2 100644 (file)
@@ -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);