Commit 15d176c1 authored by Kinglong Mee's avatar Kinglong Mee Committed by J. Bruce Fields

NFSD: Fix a memory leak if nfsd4_recdir_load fail

Signed-off-by: default avatarKinglong Mee <kinglongmee@gmail.com>
Signed-off-by: default avatarJ. Bruce Fields <bfields@redhat.com>
parent c2236f14
...@@ -480,6 +480,16 @@ nfsd4_init_recdir(struct net *net) ...@@ -480,6 +480,16 @@ nfsd4_init_recdir(struct net *net)
return status; return status;
} }
static void
nfsd4_shutdown_recdir(struct net *net)
{
struct nfsd_net *nn = net_generic(net, nfsd_net_id);
if (!nn->rec_file)
return;
fput(nn->rec_file);
nn->rec_file = NULL;
}
static int static int
nfs4_legacy_state_init(struct net *net) nfs4_legacy_state_init(struct net *net)
...@@ -513,10 +523,13 @@ nfsd4_load_reboot_recovery_data(struct net *net) ...@@ -513,10 +523,13 @@ nfsd4_load_reboot_recovery_data(struct net *net)
int status; int status;
status = nfsd4_init_recdir(net); status = nfsd4_init_recdir(net);
if (!status)
status = nfsd4_recdir_load(net);
if (status) if (status)
printk(KERN_ERR "NFSD: Failure reading reboot recovery data\n"); return status;
status = nfsd4_recdir_load(net);
if (status)
nfsd4_shutdown_recdir(net);
return status; return status;
} }
...@@ -546,22 +559,13 @@ nfsd4_legacy_tracking_init(struct net *net) ...@@ -546,22 +559,13 @@ nfsd4_legacy_tracking_init(struct net *net)
return status; return status;
} }
static void
nfsd4_shutdown_recdir(struct nfsd_net *nn)
{
if (!nn->rec_file)
return;
fput(nn->rec_file);
nn->rec_file = NULL;
}
static void static void
nfsd4_legacy_tracking_exit(struct net *net) nfsd4_legacy_tracking_exit(struct net *net)
{ {
struct nfsd_net *nn = net_generic(net, nfsd_net_id); struct nfsd_net *nn = net_generic(net, nfsd_net_id);
nfs4_release_reclaim(nn); nfs4_release_reclaim(nn);
nfsd4_shutdown_recdir(nn); nfsd4_shutdown_recdir(net);
nfs4_legacy_state_shutdown(net); nfs4_legacy_state_shutdown(net);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment