Re: [PATCH 03/14] nfsd: Fix memory leak of so_owner.data in nfs4_stateowner

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Good catch, but could we make a common nfs4_free_stateowner() helper
called both from here and nfs4_put_stateowner() so we only have to do
the kfree() in that one place?

--b.

On Mon, Jul 13, 2015 at 05:30:21PM +0800, Kinglong Mee wrote:
> Signed-off-by: Kinglong Mee <kinglongmee@xxxxxxxxx>
> ---
>  fs/nfsd/nfs4state.c | 10 +++++++---
>  1 file changed, 7 insertions(+), 3 deletions(-)
> 
> diff --git a/fs/nfsd/nfs4state.c b/fs/nfsd/nfs4state.c
> index b1f84fc..e5e14fa 100644
> --- a/fs/nfsd/nfs4state.c
> +++ b/fs/nfsd/nfs4state.c
> @@ -3316,8 +3316,10 @@ alloc_init_open_stateowner(unsigned int strhashval, struct nfsd4_open *open,
>  	if (ret == NULL) {
>  		hash_openowner(oo, clp, strhashval);
>  		ret = oo;
> -	} else
> +	} else {
> +		kfree(oo->oo_owner.so_owner.data);
>  		nfs4_free_openowner(&oo->oo_owner);
> +	}
>  	spin_unlock(&clp->cl_lock);
>  	return ret;
>  }
> @@ -5217,8 +5219,10 @@ alloc_init_lock_stateowner(unsigned int strhashval, struct nfs4_client *clp,
>  		list_add(&lo->lo_owner.so_strhash,
>  			 &clp->cl_ownerstr_hashtbl[strhashval]);
>  		ret = lo;
> -	} else
> -		nfs4_free_lockowner(&lo->lo_owner);
> +	} else {
> +		kfree(lo->lo_owner.so_owner.data);
> +		nfs4_free_openowner(&lo->lo_owner);
> +	}
>  	spin_unlock(&clp->cl_lock);
>  	return ret;
>  }
> -- 
> 2.4.3
--
To unsubscribe from this list: send the line "unsubscribe linux-nfs" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Linux Filesystem Development]     [Linux USB Development]     [Linux Media Development]     [Video for Linux]     [Linux NILFS]     [Linux Audio Users]     [Yosemite Info]     [Linux SCSI]

  Powered by Linux