From: NeilBrown <neilb@suse.com>
Subject: nfsd: always check return value of find_any_file
Patch-mainline: v5.8-rc7
Git-commit: 9affa435817711861d774f5626c393c80f16d044 (partial)
References: bsc#1172208
find_any_file() can return NULL - particularly if it races with move_to_close_lru().
So add tests to nfs4_show_open() and nfs4_show_lock()
Signed-off-by: NeilBrown <neilb@suse.com>
---
fs/nfsd/nfs4state.c | 4 ++++
1 file changed, 4 insertions(+)
--- a/fs/nfsd/nfs4state.c
+++ b/fs/nfsd/nfs4state.c
@@ -2364,6 +2364,8 @@ static int nfs4_show_open(struct seq_fil
oo = ols->st_stateowner;
nf = st->sc_file;
file = find_any_file(nf);
+ if (!file)
+ return SEQ_SKIP;
seq_printf(s, "- 0x%16phN: { type: open, ", &st->sc_stateid);
@@ -2397,6 +2399,8 @@ static int nfs4_show_lock(struct seq_fil
oo = ols->st_stateowner;
nf = st->sc_file;
file = find_any_file(nf);
+ if (!file)
+ return SEQ_SKIP;
seq_printf(s, "- 0x%16phN: { type: lock, ", &st->sc_stateid);