diff mbox

[1/1] rds: fix memory leak error

Message ID 1487928481-1022-1-git-send-email-yanjun.zhu@oracle.com
State Accepted, archived
Delegated to: David Miller
Headers show

Commit Message

Zhu Yanjun Feb. 24, 2017, 9:28 a.m. UTC
When the function register_netdevice_notifier fails, the memory
allocated by kmem_cache_create should be freed by the function
kmem_cache_destroy.

Cc: Joe Jin <joe.jin@oracle.com>
Cc: Junxiao Bi <junxiao.bi@oracle.com>
Signed-off-by: Zhu Yanjun <yanjun.zhu@oracle.com>
---
 net/rds/tcp.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

Comments

Santosh Shilimkar Feb. 24, 2017, 4:49 p.m. UTC | #1
On 2/24/2017 1:28 AM, Zhu Yanjun wrote:
> When the function register_netdevice_notifier fails, the memory
> allocated by kmem_cache_create should be freed by the function
> kmem_cache_destroy.
>
> Cc: Joe Jin <joe.jin@oracle.com>
> Cc: Junxiao Bi <junxiao.bi@oracle.com>
> Signed-off-by: Zhu Yanjun <yanjun.zhu@oracle.com>
> ---
Minor nit with subject.
s/rds/RDS: TCP:

patch looks fine to me.
Acked:by: Santosh Shilimkar <santosh.shilimkar@oracle.com>
Sowmini Varadhan Feb. 24, 2017, 5:21 p.m. UTC | #2
On 02/24/2017 04:28 AM, Zhu Yanjun wrote:
> When the function register_netdevice_notifier fails, the memory
> allocated by kmem_cache_create should be freed by the function
> kmem_cache_destroy.
>
> Cc: Joe Jin <joe.jin@oracle.com>
> Cc: Junxiao Bi <junxiao.bi@oracle.com>
> Signed-off-by: Zhu Yanjun <yanjun.zhu@oracle.com>

Acked-by: Sowmini Varadhan <sowmini.varadhan@oracle.com>
David Miller Feb. 24, 2017, 7:12 p.m. UTC | #3
From: Santosh Shilimkar <santosh.shilimkar@oracle.com>
Date: Fri, 24 Feb 2017 08:49:19 -0800

> On 2/24/2017 1:28 AM, Zhu Yanjun wrote:
>> When the function register_netdevice_notifier fails, the memory
>> allocated by kmem_cache_create should be freed by the function
>> kmem_cache_destroy.
>>
>> Cc: Joe Jin <joe.jin@oracle.com>
>> Cc: Junxiao Bi <junxiao.bi@oracle.com>
>> Signed-off-by: Zhu Yanjun <yanjun.zhu@oracle.com>
>> ---
> Minor nit with subject.
> s/rds/RDS: TCP:

Please, I definitely prefer people use all lowercase letters for
the susbsystem prefix in the subject line.
David Miller Feb. 24, 2017, 7:13 p.m. UTC | #4
From: Zhu Yanjun <yanjun.zhu@oracle.com>
Date: Fri, 24 Feb 2017 04:28:01 -0500

> When the function register_netdevice_notifier fails, the memory
> allocated by kmem_cache_create should be freed by the function
> kmem_cache_destroy.
> 
> Cc: Joe Jin <joe.jin@oracle.com>
> Cc: Junxiao Bi <junxiao.bi@oracle.com>
> Signed-off-by: Zhu Yanjun <yanjun.zhu@oracle.com>

Applied, thank you.
Santosh Shilimkar Feb. 24, 2017, 7:20 p.m. UTC | #5
On 2/24/17 11:12 AM, David Miller wrote:
> From: Santosh Shilimkar <santosh.shilimkar@oracle.com>
> Date: Fri, 24 Feb 2017 08:49:19 -0800
>
>> On 2/24/2017 1:28 AM, Zhu Yanjun wrote:
>>> When the function register_netdevice_notifier fails, the memory
>>> allocated by kmem_cache_create should be freed by the function
>>> kmem_cache_destroy.
>>>
>>> Cc: Joe Jin <joe.jin@oracle.com>
>>> Cc: Junxiao Bi <junxiao.bi@oracle.com>
>>> Signed-off-by: Zhu Yanjun <yanjun.zhu@oracle.com>
>>> ---
>> Minor nit with subject.
>> s/rds/RDS: TCP:
>
> Please, I definitely prefer people use all lowercase letters for
> the susbsystem prefix in the subject line.
>
Note for the future. Thanks Dave !!

Regards,
Santosh
diff mbox

Patch

diff --git a/net/rds/tcp.c b/net/rds/tcp.c
index 57bb523..5438f67 100644
--- a/net/rds/tcp.c
+++ b/net/rds/tcp.c
@@ -641,12 +641,12 @@  static int rds_tcp_init(void)
 	ret = register_netdevice_notifier(&rds_tcp_dev_notifier);
 	if (ret) {
 		pr_warn("could not register rds_tcp_dev_notifier\n");
-		goto out;
+		goto out_slab;
 	}
 
 	ret = register_pernet_subsys(&rds_tcp_net_ops);
 	if (ret)
-		goto out_slab;
+		goto out_notifier;
 
 	ret = rds_tcp_recv_init();
 	if (ret)
@@ -664,9 +664,10 @@  static int rds_tcp_init(void)
 	rds_tcp_recv_exit();
 out_pernet:
 	unregister_pernet_subsys(&rds_tcp_net_ops);
-out_slab:
+out_notifier:
 	if (unregister_netdevice_notifier(&rds_tcp_dev_notifier))
 		pr_warn("could not unregister rds_tcp_dev_notifier\n");
+out_slab:
 	kmem_cache_destroy(rds_tcp_conn_slab);
 out:
 	return ret;