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>
This commit is contained in:
parent
3cbe01a94c
commit
315f3812db
|
@ -905,6 +905,12 @@ static void xs_tcp_close(struct rpc_xprt *xprt)
|
||||||
xs_tcp_shutdown(xprt);
|
xs_tcp_shutdown(xprt);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void xs_xprt_free(struct rpc_xprt *xprt)
|
||||||
|
{
|
||||||
|
xs_free_peer_addresses(xprt);
|
||||||
|
xprt_free(xprt);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* xs_destroy - prepare to shutdown a transport
|
* xs_destroy - prepare to shutdown a transport
|
||||||
* @xprt: doomed transport
|
* @xprt: doomed transport
|
||||||
|
@ -915,8 +921,7 @@ static void xs_destroy(struct rpc_xprt *xprt)
|
||||||
dprintk("RPC: xs_destroy xprt %p\n", xprt);
|
dprintk("RPC: xs_destroy xprt %p\n", xprt);
|
||||||
|
|
||||||
xs_close(xprt);
|
xs_close(xprt);
|
||||||
xs_free_peer_addresses(xprt);
|
xs_xprt_free(xprt);
|
||||||
xprt_free(xprt);
|
|
||||||
module_put(THIS_MODULE);
|
module_put(THIS_MODULE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2740,7 +2745,7 @@ static struct rpc_xprt *xs_setup_local(struct xprt_create *args)
|
||||||
return xprt;
|
return xprt;
|
||||||
ret = ERR_PTR(-EINVAL);
|
ret = ERR_PTR(-EINVAL);
|
||||||
out_err:
|
out_err:
|
||||||
xprt_free(xprt);
|
xs_xprt_free(xprt);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2818,7 +2823,7 @@ static struct rpc_xprt *xs_setup_udp(struct xprt_create *args)
|
||||||
return xprt;
|
return xprt;
|
||||||
ret = ERR_PTR(-EINVAL);
|
ret = ERR_PTR(-EINVAL);
|
||||||
out_err:
|
out_err:
|
||||||
xprt_free(xprt);
|
xs_xprt_free(xprt);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2893,12 +2898,11 @@ static struct rpc_xprt *xs_setup_tcp(struct xprt_create *args)
|
||||||
xprt->address_strings[RPC_DISPLAY_ADDR],
|
xprt->address_strings[RPC_DISPLAY_ADDR],
|
||||||
xprt->address_strings[RPC_DISPLAY_PROTO]);
|
xprt->address_strings[RPC_DISPLAY_PROTO]);
|
||||||
|
|
||||||
|
|
||||||
if (try_module_get(THIS_MODULE))
|
if (try_module_get(THIS_MODULE))
|
||||||
return xprt;
|
return xprt;
|
||||||
ret = ERR_PTR(-EINVAL);
|
ret = ERR_PTR(-EINVAL);
|
||||||
out_err:
|
out_err:
|
||||||
xprt_free(xprt);
|
xs_xprt_free(xprt);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2981,13 +2985,12 @@ static struct rpc_xprt *xs_setup_bc_tcp(struct xprt_create *args)
|
||||||
*/
|
*/
|
||||||
xprt_set_connected(xprt);
|
xprt_set_connected(xprt);
|
||||||
|
|
||||||
|
|
||||||
if (try_module_get(THIS_MODULE))
|
if (try_module_get(THIS_MODULE))
|
||||||
return xprt;
|
return xprt;
|
||||||
xprt_put(xprt);
|
xprt_put(xprt);
|
||||||
ret = ERR_PTR(-EINVAL);
|
ret = ERR_PTR(-EINVAL);
|
||||||
out_err:
|
out_err:
|
||||||
xprt_free(xprt);
|
xs_xprt_free(xprt);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue