Commit 3b5923f0796b13e731802d40faf62d2c59d98e48
Committed by
David S. Miller
1 parent
1158632b5a
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>
Showing 1 changed file with 4 additions and 3 deletions Side-by-side Diff
net/rds/tcp.c
... | ... | @@ -641,12 +641,12 @@ |
641 | 641 | ret = register_netdevice_notifier(&rds_tcp_dev_notifier); |
642 | 642 | if (ret) { |
643 | 643 | pr_warn("could not register rds_tcp_dev_notifier\n"); |
644 | - goto out; | |
644 | + goto out_slab; | |
645 | 645 | } |
646 | 646 | |
647 | 647 | ret = register_pernet_subsys(&rds_tcp_net_ops); |
648 | 648 | if (ret) |
649 | - goto out_slab; | |
649 | + goto out_notifier; | |
650 | 650 | |
651 | 651 | ret = rds_tcp_recv_init(); |
652 | 652 | if (ret) |
653 | 653 | |
... | ... | @@ -664,9 +664,10 @@ |
664 | 664 | rds_tcp_recv_exit(); |
665 | 665 | out_pernet: |
666 | 666 | unregister_pernet_subsys(&rds_tcp_net_ops); |
667 | -out_slab: | |
667 | +out_notifier: | |
668 | 668 | if (unregister_netdevice_notifier(&rds_tcp_dev_notifier)) |
669 | 669 | pr_warn("could not unregister rds_tcp_dev_notifier\n"); |
670 | +out_slab: | |
670 | 671 | kmem_cache_destroy(rds_tcp_conn_slab); |
671 | 672 | out: |
672 | 673 | return ret; |