diff options
author | Zhu Yanjun <yanjun.zhu@oracle.com> | 2017-02-24 04:28:01 -0500 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2017-02-24 14:13:14 -0500 |
commit | 3b5923f0796b13e731802d40faf62d2c59d98e48 (patch) | |
tree | ecf819039abb0ac6715ae135ca1f838ed0a0b5b3 /net/rds/tcp.c | |
parent | 1158632b5a2dcce0786c1b1b99654e81cc867981 (diff) | |
download | linux-3b5923f0796b13e731802d40faf62d2c59d98e48.tar.gz linux-3b5923f0796b13e731802d40faf62d2c59d98e48.tar.bz2 linux-3b5923f0796b13e731802d40faf62d2c59d98e48.zip |
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.
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: Santosh Shilimkar <santosh.shilimkar@oracle.com>
Acked-by: Sowmini Varadhan <sowmini.varadhan@oracle.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/rds/tcp.c')
-rw-r--r-- | net/rds/tcp.c | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/net/rds/tcp.c b/net/rds/tcp.c index 57bb52361e0f..5438f6725092 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 @@ out_recv: 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; |