Skip to content

Commit 2ffda63

Browse files
Sicong Huangchucklever
authored andcommitted
NFSD: clean up alloc_init_deleg()
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>
1 parent 6939ace commit 2ffda63

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

fs/nfsd/nfs4state.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1160,6 +1160,7 @@ alloc_init_deleg(struct nfs4_client *clp, struct nfs4_file *fp,
11601160
struct nfs4_clnt_odstate *odstate, u32 dl_type)
11611161
{
11621162
struct nfs4_delegation *dp;
1163+
struct nfs4_stid *stid;
11631164
long n;
11641165

11651166
dprintk("NFSD alloc_init_deleg\n");
@@ -1168,9 +1169,10 @@ alloc_init_deleg(struct nfs4_client *clp, struct nfs4_file *fp,
11681169
goto out_dec;
11691170
if (delegation_blocked(&fp->fi_fhandle))
11701171
goto out_dec;
1171-
dp = delegstateid(nfs4_alloc_stid(clp, deleg_slab, nfs4_free_deleg));
1172-
if (dp == NULL)
1172+
stid = nfs4_alloc_stid(clp, deleg_slab, nfs4_free_deleg);
1173+
if (stid == NULL)
11731174
goto out_dec;
1175+
dp = delegstateid(stid);
11741176

11751177
/*
11761178
* delegation seqid's are never incremented. The 4.1 special

0 commit comments

Comments
 (0)