Skip to contentSkip to conversation

rds: fix memory leak error

PATCH In review Zhu Yanjun 5 participants 6 messages Feb 24, 2017 2 messages not in the archive

Subsystems (4)
lore
Share & tools
lore

Zhu Yanjun

author
#0 lore raw

PATCH 1/1 rds: fix memory leak error

When the function register_netdevice_notifier fails, the memory allocated by kmem_cache_create should be freed by the function kmem_cache_destroy.

---
 net/rds/tcp.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)
net/rds/tcp.c +4 -3
index 57bb523..5438f67 100644
@@ -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;
Signature · 6 lines
2.7.4

--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
#2 lore raw
In reply to a message not in the archive
Quoted 8 lines · Zhu Yanjun

When the function register_netdevice_notifier fails, the memory allocated by kmem_cache_create should be freed by the function kmem_cache_destroy.

---

Minor nit with subject.
s/rds/RDS: TCP:

patch looks fine to me.
Acked:by: Santosh Shilimkar <[email protected]> --
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

Acked-by
#6 lore raw
In reply to a message not in the archive
Quoted 7 lines · Zhu Yanjun

When the function register_netdevice_notifier fails, the memory allocated by kmem_cache_create should be freed by the function kmem_cache_destroy.

--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

#4 lore raw
In reply to a message not in the archive

From: Santosh Shilimkar <[email protected]>
Date: Fri, 24 Feb 2017 08:49:19 -0800

Quoted 11 lines · Zhu Yanjun
Quoted 8 lines

When the function register_netdevice_notifier fails, the memory allocated by kmem_cache_create should be freed by the function kmem_cache_destroy.

---

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.
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

#7 lore raw
In reply to a message not in the archive

From: Zhu Yanjun <[email protected]>
Date: Fri, 24 Feb 2017 04:28:01 -0500

Quoted 7 lines

When the function register_netdevice_notifier fails, the memory allocated by kmem_cache_create should be freed by the function kmem_cache_destroy.

Applied, thank you.
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

#5 lore raw
In reply to David Miller
Quoted 12 lines · David Miller

From: Santosh Shilimkar <[email protected]>
Date: Fri, 24 Feb 2017 08:49:19 -0800

Quoted 9 lines · Zhu Yanjun
Quoted 8 lines

When the function register_netdevice_notifier fails, the memory allocated by kmem_cache_create should be freed by the function kmem_cache_destroy.

---

Quoted 6 lines
Quoted 2 lines

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