nfs: plug memory leak when ->prepare_layoutcommit fails

"data" is currently leaked when the prepare_layoutcommit operation
returns an error. Put the cred before taking the spinlock in that
case, take the lock and then goto out_unlock which will drop the
lock and then free "data".

Signed-off-by: Jeff Layton <jeff.layton@primarydata.com>
Signed-off-by: Trond Myklebust <trond.myklebust@primarydata.com>
This commit is contained in:
Jeff Layton 2015-07-10 15:58:42 -04:00 committed by Trond Myklebust
parent f580dd0428
commit 3471648a75

View file

@ -2221,13 +2221,12 @@ pnfs_layoutcommit_inode(struct inode *inode, bool sync)
if (ld->prepare_layoutcommit) { if (ld->prepare_layoutcommit) {
status = ld->prepare_layoutcommit(&data->args); status = ld->prepare_layoutcommit(&data->args);
if (status) { if (status) {
put_rpccred(data->cred);
spin_lock(&inode->i_lock); spin_lock(&inode->i_lock);
set_bit(NFS_INO_LAYOUTCOMMIT, &nfsi->flags); set_bit(NFS_INO_LAYOUTCOMMIT, &nfsi->flags);
if (end_pos > nfsi->layout->plh_lwb) if (end_pos > nfsi->layout->plh_lwb)
nfsi->layout->plh_lwb = end_pos; nfsi->layout->plh_lwb = end_pos;
spin_unlock(&inode->i_lock); goto out_unlock;
put_rpccred(data->cred);
goto clear_layoutcommitting;
} }
} }