Skip to content

Commit

Permalink
NFSD: clean up alloc_init_deleg()
Browse files Browse the repository at this point in the history
Modify the conditional statement for null pointer check in the function
'alloc_init_deleg' to make this function more robust and clear. Otherwise,
this function may have potential pointer dereference problem in the future,
when modifying or expanding the nfs4_delegation structure.

Signed-off-by: Sicong Huang <huangsicong@iie.ac.cn>
Reviewed-by: Jeff Layton <jlayton@kernel.org>
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
  • Loading branch information
Sicong Huang authored and Chuck Lever committed Oct 16, 2023
1 parent 6939ace commit 2ffda63
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions fs/nfsd/nfs4state.c
Original file line number Diff line number Diff line change
Expand Up @@ -1160,6 +1160,7 @@ alloc_init_deleg(struct nfs4_client *clp, struct nfs4_file *fp,
struct nfs4_clnt_odstate *odstate, u32 dl_type)
{
struct nfs4_delegation *dp;
struct nfs4_stid *stid;
long n;

dprintk("NFSD alloc_init_deleg\n");
Expand All @@ -1168,9 +1169,10 @@ alloc_init_deleg(struct nfs4_client *clp, struct nfs4_file *fp,
goto out_dec;
if (delegation_blocked(&fp->fi_fhandle))
goto out_dec;
dp = delegstateid(nfs4_alloc_stid(clp, deleg_slab, nfs4_free_deleg));
if (dp == NULL)
stid = nfs4_alloc_stid(clp, deleg_slab, nfs4_free_deleg);
if (stid == NULL)
goto out_dec;
dp = delegstateid(stid);

/*
* delegation seqid's are never incremented. The 4.1 special
Expand Down

0 comments on commit 2ffda63

Please sign in to comment.