OpenVZ Forum


Home » Mailing lists » Devel » [PATCH] NFS: put net in case of idr allocation failure
[PATCH] NFS: put net in case of idr allocation failure [message #47612] Mon, 20 August 2012 13:43 Go to next message
Stanislav Kinsbursky is currently offline  Stanislav Kinsbursky
Messages: 683
Registered: October 2011
Senior Member
From: *parallels.com
Put net reference we got in nfs_alloc_client() on error path.

Signed-off-by: Stanislav Kinsbursky <skinsbursky@parallels.com>
---
fs/nfs/nfs4client.c | 1 +
1 files changed, 1 insertions(+), 0 deletions(-)

diff --git a/fs/nfs/nfs4client.c b/fs/nfs/nfs4client.c
index cbcdfaf..b895629 100644
--- a/fs/nfs/nfs4client.c
+++ b/fs/nfs/nfs4client.c
@@ -74,6 +74,7 @@ struct nfs_client *nfs4_alloc_client(const struct nfs_client_initdata *cl_init)
return clp;

error:
+ put_net(clp->cl_net);
kfree(clp);
return ERR_PTR(err);
}
Re: [PATCH] NFS: put net in case of idr allocation failure [message #47628 is a reply to message #47612] Mon, 20 August 2012 16:14 Go to previous message
Stanislav Kinsbursky is currently offline  Stanislav Kinsbursky
Messages: 683
Registered: October 2011
Senior Member
From: *parallels.com
20.08.2012 20:11, Myklebust, Trond пишет:
> On Mon, 2012-08-20 at 17:43 +0400, Stanislav Kinsbursky wrote:
>> Put net reference we got in nfs_alloc_client() on error path.
>>
>> Signed-off-by: Stanislav Kinsbursky <skinsbursky@parallels.com>
>> ---
>> fs/nfs/nfs4client.c | 1 +
>> 1 files changed, 1 insertions(+), 0 deletions(-)
>>
>> diff --git a/fs/nfs/nfs4client.c b/fs/nfs/nfs4client.c
>> index cbcdfaf..b895629 100644
>> --- a/fs/nfs/nfs4client.c
>> +++ b/fs/nfs/nfs4client.c
>> @@ -74,6 +74,7 @@ struct nfs_client *nfs4_alloc_client(const struct nfs_client_initdata *cl_init)
>> return clp;
>>
>> error:
>> + put_net(clp->cl_net);
>> kfree(clp);
>> return ERR_PTR(err);
>> }
>
>
> No, that isn't anywhere near sufficient.
>
> The correct thing to do here is to replace the kfree with a call to
> nfs_free_client(), which will also clean up the allocation of
> cl_hostname, put the module, etc.
>

Sure, you are right.

--
Best regards,
Stanislav Kinsbursky
Re: [PATCH] NFS: put net in case of idr allocation failure [message #47630 is a reply to message #47612] Mon, 20 August 2012 16:11 Go to previous message
Myklebust, Trond is currently offline  Myklebust, Trond
Messages: 52
Registered: November 2011
Member
From: 10.104.60*
On Mon, 2012-08-20 at 17:43 +0400, Stanislav Kinsbursky wrote:
> Put net reference we got in nfs_alloc_client() on error path.
>
> Signed-off-by: Stanislav Kinsbursky <skinsbursky@parallels.com>
> ---
> fs/nfs/nfs4client.c | 1 +
> 1 files changed, 1 insertions(+), 0 deletions(-)
>
> diff --git a/fs/nfs/nfs4client.c b/fs/nfs/nfs4client.c
> index cbcdfaf..b895629 100644
> --- a/fs/nfs/nfs4client.c
> +++ b/fs/nfs/nfs4client.c
> @@ -74,6 +74,7 @@ struct nfs_client *nfs4_alloc_client(const struct nfs_client_initdata *cl_init)
> return clp;
>
> error:
> + put_net(clp->cl_net);
> kfree(clp);
> return ERR_PTR(err);
> }


No, that isn't anywhere near sufficient.

The correct thing to do here is to replace the kfree with a call to
nfs_free_client(), which will also clean up the allocation of
cl_hostname, put the module, etc.

--
Trond Myklebust
Linux NFS client maintainer

NetApp
Trond.Myklebust@netapp.com
www.netapp.com
Previous Topic: [PATCH v4 00/10] NFS: callback threads containerization
Next Topic: [PATCH] NFS: free client is case of idr allocation failure
Goto Forum:
  


Current Time: Sun Dec 16 23:58:23 GMT 2018