aboutsummaryrefslogtreecommitdiffstats
path: root/net/sunrpc
diff options
context:
space:
mode:
authorKinglong Mee <kinglongmee@gmail.com>2014-03-23 23:07:22 -0400
committerJ. Bruce Fields <bfields@redhat.com>2014-03-28 21:23:39 -0400
commit315f3812dbd92c7c8f26a8dbba183266ec219795 (patch)
tree883153bcf809468e042f1df53e09511e930cee9d /net/sunrpc
parent3cbe01a94c7b369f943f8a9d40394198d757cdd4 (diff)
SUNRPC: fix memory leak of peer addresses in XPRT
Creating xprt failed after xs_format_peer_addresses, sunrpc must free those memory of peer addresses in xprt. Signed-off-by: Kinglong Mee <kinglongmee@gmail.com> Signed-off-by: J. Bruce Fields <bfields@redhat.com>
Diffstat (limited to 'net/sunrpc')
-rw-r--r--net/sunrpc/xprtsock.c19
1 files changed, 11 insertions, 8 deletions
diff --git a/net/sunrpc/xprtsock.c b/net/sunrpc/xprtsock.c
index 817a1e523969..4b921a926994 100644
--- a/net/sunrpc/xprtsock.c
+++ b/net/sunrpc/xprtsock.c
@@ -905,6 +905,12 @@ static void xs_tcp_close(struct rpc_xprt *xprt)
905 xs_tcp_shutdown(xprt); 905 xs_tcp_shutdown(xprt);
906} 906}
907 907
908static void xs_xprt_free(struct rpc_xprt *xprt)
909{
910 xs_free_peer_addresses(xprt);
911 xprt_free(xprt);
912}
913
908/** 914/**
909 * xs_destroy - prepare to shutdown a transport 915 * xs_destroy - prepare to shutdown a transport
910 * @xprt: doomed transport 916 * @xprt: doomed transport
@@ -915,8 +921,7 @@ static void xs_destroy(struct rpc_xprt *xprt)
915 dprintk("RPC: xs_destroy xprt %p\n", xprt); 921 dprintk("RPC: xs_destroy xprt %p\n", xprt);
916 922
917 xs_close(xprt); 923 xs_close(xprt);
918 xs_free_peer_addresses(xprt); 924 xs_xprt_free(xprt);
919 xprt_free(xprt);
920 module_put(THIS_MODULE); 925 module_put(THIS_MODULE);
921} 926}
922 927
@@ -2740,7 +2745,7 @@ static struct rpc_xprt *xs_setup_local(struct xprt_create *args)
2740 return xprt; 2745 return xprt;
2741 ret = ERR_PTR(-EINVAL); 2746 ret = ERR_PTR(-EINVAL);
2742out_err: 2747out_err:
2743 xprt_free(xprt); 2748 xs_xprt_free(xprt);
2744 return ret; 2749 return ret;
2745} 2750}
2746 2751
@@ -2818,7 +2823,7 @@ static struct rpc_xprt *xs_setup_udp(struct xprt_create *args)
2818 return xprt; 2823 return xprt;
2819 ret = ERR_PTR(-EINVAL); 2824 ret = ERR_PTR(-EINVAL);
2820out_err: 2825out_err:
2821 xprt_free(xprt); 2826 xs_xprt_free(xprt);
2822 return ret; 2827 return ret;
2823} 2828}
2824 2829
@@ -2893,12 +2898,11 @@ static struct rpc_xprt *xs_setup_tcp(struct xprt_create *args)
2893 xprt->address_strings[RPC_DISPLAY_ADDR], 2898 xprt->address_strings[RPC_DISPLAY_ADDR],
2894 xprt->address_strings[RPC_DISPLAY_PROTO]); 2899 xprt->address_strings[RPC_DISPLAY_PROTO]);
2895 2900
2896
2897 if (try_module_get(THIS_MODULE)) 2901 if (try_module_get(THIS_MODULE))
2898 return xprt; 2902 return xprt;
2899 ret = ERR_PTR(-EINVAL); 2903 ret = ERR_PTR(-EINVAL);
2900out_err: 2904out_err:
2901 xprt_free(xprt); 2905 xs_xprt_free(xprt);
2902 return ret; 2906 return ret;
2903} 2907}
2904 2908
@@ -2981,13 +2985,12 @@ static struct rpc_xprt *xs_setup_bc_tcp(struct xprt_create *args)
2981 */ 2985 */
2982 xprt_set_connected(xprt); 2986 xprt_set_connected(xprt);
2983 2987
2984
2985 if (try_module_get(THIS_MODULE)) 2988 if (try_module_get(THIS_MODULE))
2986 return xprt; 2989 return xprt;
2987 xprt_put(xprt); 2990 xprt_put(xprt);
2988 ret = ERR_PTR(-EINVAL); 2991 ret = ERR_PTR(-EINVAL);
2989out_err: 2992out_err:
2990 xprt_free(xprt); 2993 xs_xprt_free(xprt);
2991 return ret; 2994 return ret;
2992} 2995}
2993 2996