Skip to content

Commit

Permalink
SUNRPC: Fix unx_lookup_cred() allocation
Browse files Browse the repository at this point in the history
Default to the same mempool allocation strategy as for rpc_malloc().

Signed-off-by: Trond Myklebust <trond.myklebust@hammerspace.com>
  • Loading branch information
Trond Myklebust committed Mar 22, 2022
1 parent 910ad38 commit 059ee82
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions net/sunrpc/auth_unix.c
Original file line number Diff line number Diff line change
Expand Up @@ -40,17 +40,19 @@ unx_destroy(struct rpc_auth *auth)
/*
* Lookup AUTH_UNIX creds for current process
*/
static struct rpc_cred *
unx_lookup_cred(struct rpc_auth *auth, struct auth_cred *acred, int flags)
static struct rpc_cred *unx_lookup_cred(struct rpc_auth *auth,
struct auth_cred *acred, int flags)
{
gfp_t gfp = GFP_KERNEL;
struct rpc_cred *ret;

if (flags & RPCAUTH_LOOKUP_ASYNC)
gfp = GFP_NOWAIT | __GFP_NOWARN;
ret = mempool_alloc(unix_pool, gfp);
if (!ret)
return ERR_PTR(-ENOMEM);
ret = kmalloc(sizeof(*ret), rpc_task_gfp_mask());
if (!ret) {
if (!(flags & RPCAUTH_LOOKUP_ASYNC))
return ERR_PTR(-ENOMEM);
ret = mempool_alloc(unix_pool, GFP_NOWAIT);
if (!ret)
return ERR_PTR(-ENOMEM);
}
rpcauth_init_cred(ret, acred, auth, &unix_credops);
ret->cr_flags = 1UL << RPCAUTH_CRED_UPTODATE;
return ret;
Expand Down

0 comments on commit 059ee82

Please sign in to comment.