diff options
author | J. Bruce Fields <bfields@redhat.com> | 2011-01-31 17:14:55 -0500 |
---|---|---|
committer | J. Bruce Fields <bfields@redhat.com> | 2011-02-14 10:35:18 -0500 |
commit | dd239cc05f0ad9f582dd83d88a4fb5edcc57a026 (patch) | |
tree | ea1a50af9405d104d5c98620eed4ca10bf131df6 /fs | |
parent | 22d38c4c10e8344aa406897d99a35d585d2cb77d (diff) |
nfsd4: fix leak on allocation error
Also share some common exit code.
Signed-off-by: J. Bruce Fields <bfields@redhat.com>
Diffstat (limited to 'fs')
-rw-r--r-- | fs/nfsd/nfs4state.c | 18 |
1 files changed, 10 insertions, 8 deletions
diff --git a/fs/nfsd/nfs4state.c b/fs/nfsd/nfs4state.c index 65978a9aa877..099d6fa64f7f 100644 --- a/fs/nfsd/nfs4state.c +++ b/fs/nfsd/nfs4state.c | |||
@@ -2699,14 +2699,12 @@ nfs4_open_delegation(struct svc_fh *fh, struct nfsd4_open *open, struct nfs4_sta | |||
2699 | } | 2699 | } |
2700 | 2700 | ||
2701 | dp = alloc_init_deleg(sop->so_client, stp, fh, flag); | 2701 | dp = alloc_init_deleg(sop->so_client, stp, fh, flag); |
2702 | if (dp == NULL) { | 2702 | if (dp == NULL) |
2703 | flag = NFS4_OPEN_DELEGATE_NONE; | 2703 | goto out_no_deleg; |
2704 | goto out; | ||
2705 | } | ||
2706 | status = -ENOMEM; | 2704 | status = -ENOMEM; |
2707 | fl = nfs4_alloc_init_lease(dp, flag); | 2705 | fl = nfs4_alloc_init_lease(dp, flag); |
2708 | if (!fl) | 2706 | if (!fl) |
2709 | goto out; | 2707 | goto out_free; |
2710 | /* vfs_setlease checks to see if delegation should be handed out. | 2708 | /* vfs_setlease checks to see if delegation should be handed out. |
2711 | * the lock_manager callback fl_change is used | 2709 | * the lock_manager callback fl_change is used |
2712 | */ | 2710 | */ |
@@ -2714,9 +2712,7 @@ nfs4_open_delegation(struct svc_fh *fh, struct nfsd4_open *open, struct nfs4_sta | |||
2714 | dprintk("NFSD: setlease failed [%d], no delegation\n", status); | 2712 | dprintk("NFSD: setlease failed [%d], no delegation\n", status); |
2715 | dp->dl_flock = NULL; | 2713 | dp->dl_flock = NULL; |
2716 | locks_free_lock(fl); | 2714 | locks_free_lock(fl); |
2717 | unhash_delegation(dp); | 2715 | goto out_free; |
2718 | flag = NFS4_OPEN_DELEGATE_NONE; | ||
2719 | goto out; | ||
2720 | } | 2716 | } |
2721 | 2717 | ||
2722 | memcpy(&open->op_delegate_stateid, &dp->dl_stateid, sizeof(dp->dl_stateid)); | 2718 | memcpy(&open->op_delegate_stateid, &dp->dl_stateid, sizeof(dp->dl_stateid)); |
@@ -2729,6 +2725,12 @@ out: | |||
2729 | && open->op_delegate_type != NFS4_OPEN_DELEGATE_NONE) | 2725 | && open->op_delegate_type != NFS4_OPEN_DELEGATE_NONE) |
2730 | dprintk("NFSD: WARNING: refusing delegation reclaim\n"); | 2726 | dprintk("NFSD: WARNING: refusing delegation reclaim\n"); |
2731 | open->op_delegate_type = flag; | 2727 | open->op_delegate_type = flag; |
2728 | return; | ||
2729 | out_free: | ||
2730 | unhash_delegation(dp); | ||
2731 | out_no_deleg: | ||
2732 | flag = NFS4_OPEN_DELEGATE_NONE; | ||
2733 | goto out; | ||
2732 | } | 2734 | } |
2733 | 2735 | ||
2734 | /* | 2736 | /* |