]> git.baikalelectronics.ru Git - kernel.git/commitdiff
SUNRPC: Fix up open coded kmemdup_nul()
authorTrond Myklebust <trond.myklebust@hammerspace.com>
Tue, 10 Nov 2020 15:56:53 +0000 (10:56 -0500)
committerTrond Myklebust <trond.myklebust@hammerspace.com>
Wed, 2 Dec 2020 19:05:53 +0000 (14:05 -0500)
Signed-off-by: Trond Myklebust <trond.myklebust@hammerspace.com>
net/sunrpc/xdr.c

index 71e03b930b70a3ac9e84d8a50d4cefb4d5ece69f..b1cda6d85dede4cca0fe7fc9cf75bc00165f1946 100644 (file)
@@ -1942,10 +1942,8 @@ ssize_t xdr_stream_decode_string_dup(struct xdr_stream *xdr, char **str,
 
        ret = xdr_stream_decode_opaque_inline(xdr, &p, maxlen);
        if (ret > 0) {
-               char *s = kmalloc(ret + 1, gfp_flags);
+               char *s = kmemdup_nul(p, ret, gfp_flags);
                if (s != NULL) {
-                       memcpy(s, p, ret);
-                       s[ret] = '\0';
                        *str = s;
                        return strlen(s);
                }