]> git.baikalelectronics.ru Git - kernel.git/commit
nfs: make nfs4_init_nonuniform_client_string use a dynamically allocated buffer
authorJeff Layton <jlayton@poochiereds.net>
Tue, 9 Jun 2015 23:43:59 +0000 (19:43 -0400)
committerTrond Myklebust <trond.myklebust@primarydata.com>
Tue, 16 Jun 2015 15:15:45 +0000 (11:15 -0400)
commitf9c64b9327a09ddbbf6690effa22a3e01e750a0b
tree61a5c98cccfed198dc94764eea31c3f0f759d786
parenteae793f834f977aabcbe76f7a833ed57d373ee97
nfs: make nfs4_init_nonuniform_client_string use a dynamically allocated buffer

The way the *_client_string functions work is a little goofy. They build
the string in an on-stack buffer and then use kstrdup to copy it. This
is not only stack-heavy but artificially limits the size of the client
name string. Change it so that we determine the length of the string,
allocate it and then scnprintf into it.

Since the contents of the nonuniform string depend on rcu-managed data
structures, it's possible that they'll change between when we allocate
the string and when we go to fill it. If that happens, free the string,
recalculate the length and try again. If it the mismatch isn't resolved
on the second try then just give up and return -EINVAL.

Signed-off-by: Jeff Layton <jeff.layton@primarydata.com>
Signed-off-by: Trond Myklebust <trond.myklebust@primarydata.com>
fs/nfs/nfs4proc.c