Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

SUNRPC: Fix unx_lookup_cred() allocation

Default to the same mempool allocation strategy as for rpc_malloc().

Signed-off-by: Trond Myklebust <trond.myklebust@hammerspace.com>

+10 -8
+10 -8
net/sunrpc/auth_unix.c
··· 40 40 /* 41 41 * Lookup AUTH_UNIX creds for current process 42 42 */ 43 - static struct rpc_cred * 44 - unx_lookup_cred(struct rpc_auth *auth, struct auth_cred *acred, int flags) 43 + static struct rpc_cred *unx_lookup_cred(struct rpc_auth *auth, 44 + struct auth_cred *acred, int flags) 45 45 { 46 - gfp_t gfp = GFP_KERNEL; 47 46 struct rpc_cred *ret; 48 47 49 - if (flags & RPCAUTH_LOOKUP_ASYNC) 50 - gfp = GFP_NOWAIT | __GFP_NOWARN; 51 - ret = mempool_alloc(unix_pool, gfp); 52 - if (!ret) 53 - return ERR_PTR(-ENOMEM); 48 + ret = kmalloc(sizeof(*ret), rpc_task_gfp_mask()); 49 + if (!ret) { 50 + if (!(flags & RPCAUTH_LOOKUP_ASYNC)) 51 + return ERR_PTR(-ENOMEM); 52 + ret = mempool_alloc(unix_pool, GFP_NOWAIT); 53 + if (!ret) 54 + return ERR_PTR(-ENOMEM); 55 + } 54 56 rpcauth_init_cred(ret, acred, auth, &unix_credops); 55 57 ret->cr_flags = 1UL << RPCAUTH_CRED_UPTODATE; 56 58 return ret;