mirror of
https://github.com/hardkernel/linux.git
synced 2026-06-05 10:31:46 +09:00
nfsd: allow nfsd_file_get to sanely handle a NULL pointer
[ Upstream commit 70f62231cd ]
...and remove some now-useless NULL pointer checks in its callers.
Suggested-by: NeilBrown <neilb@suse.de>
Signed-off-by: Jeff Layton <jlayton@kernel.org>
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
This commit is contained in:
@@ -431,7 +431,7 @@ static bool nfsd_file_lru_remove(struct nfsd_file *nf)
|
|||||||
struct nfsd_file *
|
struct nfsd_file *
|
||||||
nfsd_file_get(struct nfsd_file *nf)
|
nfsd_file_get(struct nfsd_file *nf)
|
||||||
{
|
{
|
||||||
if (likely(refcount_inc_not_zero(&nf->nf_ref)))
|
if (nf && refcount_inc_not_zero(&nf->nf_ref))
|
||||||
return nf;
|
return nf;
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
@@ -1086,8 +1086,7 @@ retry:
|
|||||||
rcu_read_lock();
|
rcu_read_lock();
|
||||||
nf = rhashtable_lookup(&nfsd_file_rhash_tbl, &key,
|
nf = rhashtable_lookup(&nfsd_file_rhash_tbl, &key,
|
||||||
nfsd_file_rhash_params);
|
nfsd_file_rhash_params);
|
||||||
if (nf)
|
nf = nfsd_file_get(nf);
|
||||||
nf = nfsd_file_get(nf);
|
|
||||||
rcu_read_unlock();
|
rcu_read_unlock();
|
||||||
|
|
||||||
if (nf) {
|
if (nf) {
|
||||||
|
|||||||
@@ -602,9 +602,7 @@ put_nfs4_file(struct nfs4_file *fi)
|
|||||||
static struct nfsd_file *
|
static struct nfsd_file *
|
||||||
__nfs4_get_fd(struct nfs4_file *f, int oflag)
|
__nfs4_get_fd(struct nfs4_file *f, int oflag)
|
||||||
{
|
{
|
||||||
if (f->fi_fds[oflag])
|
return nfsd_file_get(f->fi_fds[oflag]);
|
||||||
return nfsd_file_get(f->fi_fds[oflag]);
|
|
||||||
return NULL;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static struct nfsd_file *
|
static struct nfsd_file *
|
||||||
|
|||||||
Reference in New Issue
Block a user