diff options
author | Chuck Lever <chuck.lever@oracle.com> | 2022-07-08 14:27:09 -0400 |
---|---|---|
committer | Chuck Lever <chuck.lever@oracle.com> | 2022-07-29 20:16:56 -0400 |
commit | 427f5f83a3191cbf024c5aea6e5b601cdf88d895 (patch) | |
tree | fdd97a04ea12d861ccf06dadd59f737845a74744 /fs/nfsd/filecache.c | |
parent | 5e138c4a750dc140d881dab4a8804b094bbc08d2 (diff) | |
download | lwn-427f5f83a3191cbf024c5aea6e5b601cdf88d895.tar.gz lwn-427f5f83a3191cbf024c5aea6e5b601cdf88d895.zip |
NFSD: Ensure nf_inode is never dereferenced
The documenting comment for struct nf_file states:
/*
* A representation of a file that has been opened by knfsd. These are hashed
* in the hashtable by inode pointer value. Note that this object doesn't
* hold a reference to the inode by itself, so the nf_inode pointer should
* never be dereferenced, only used for comparison.
*/
Replace the two existing dereferences to make the comment always
true.
Reviewed-by: Jeff Layton <jlayton@kernel.org>
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Diffstat (limited to 'fs/nfsd/filecache.c')
-rw-r--r-- | fs/nfsd/filecache.c | 5 |
1 files changed, 2 insertions, 3 deletions
diff --git a/fs/nfsd/filecache.c b/fs/nfsd/filecache.c index 58721fced7f3..57d06a2e94a2 100644 --- a/fs/nfsd/filecache.c +++ b/fs/nfsd/filecache.c @@ -228,12 +228,11 @@ nfsd_file_mark_put(struct nfsd_file_mark *nfm) } static struct nfsd_file_mark * -nfsd_file_mark_find_or_create(struct nfsd_file *nf) +nfsd_file_mark_find_or_create(struct nfsd_file *nf, struct inode *inode) { int err; struct fsnotify_mark *mark; struct nfsd_file_mark *nfm = NULL, *new; - struct inode *inode = nf->nf_inode; do { fsnotify_group_lock(nfsd_file_fsnotify_group); @@ -1144,7 +1143,7 @@ out_status: open_file: trace_nfsd_file_alloc(nf); - nf->nf_mark = nfsd_file_mark_find_or_create(nf); + nf->nf_mark = nfsd_file_mark_find_or_create(nf, key.inode); if (nf->nf_mark) { if (open) { status = nfsd_open_verified(rqstp, fhp, may_flags, |