提交 0c43b3d8 编写于 作者: C Chuck Lever 提交者: Trond Myklebust

SUNRPC: Free address buffers in a loop

Use more generic logic to free buffers holding formatted addresses.  This
makes it less likely a bug will be introduced when adding additional buffer
types in xs_format_peer_address().
Signed-off-by: NChuck Lever <chuck.lever@oracle.com>
Signed-off-by: NTrond Myklebust <Trond.Myklebust@netapp.com>
上级 bda243df
...@@ -279,10 +279,14 @@ static void xs_format_peer_addresses(struct rpc_xprt *xprt) ...@@ -279,10 +279,14 @@ static void xs_format_peer_addresses(struct rpc_xprt *xprt)
} }
xprt->address_strings[RPC_DISPLAY_PORT] = buf; xprt->address_strings[RPC_DISPLAY_PORT] = buf;
if (xprt->prot == IPPROTO_UDP) buf = kzalloc(8, GFP_KERNEL);
xprt->address_strings[RPC_DISPLAY_PROTO] = "udp"; if (buf) {
else if (xprt->prot == IPPROTO_UDP)
xprt->address_strings[RPC_DISPLAY_PROTO] = "tcp"; snprintf(buf, 8, "udp");
else
snprintf(buf, 8, "tcp");
}
xprt->address_strings[RPC_DISPLAY_PROTO] = buf;
buf = kzalloc(48, GFP_KERNEL); buf = kzalloc(48, GFP_KERNEL);
if (buf) { if (buf) {
...@@ -296,9 +300,10 @@ static void xs_format_peer_addresses(struct rpc_xprt *xprt) ...@@ -296,9 +300,10 @@ static void xs_format_peer_addresses(struct rpc_xprt *xprt)
static void xs_free_peer_addresses(struct rpc_xprt *xprt) static void xs_free_peer_addresses(struct rpc_xprt *xprt)
{ {
kfree(xprt->address_strings[RPC_DISPLAY_ADDR]); int i;
kfree(xprt->address_strings[RPC_DISPLAY_PORT]);
kfree(xprt->address_strings[RPC_DISPLAY_ALL]); for (i = 0; i < RPC_DISPLAY_MAX; i++)
kfree(xprt->address_strings[i]);
} }
#define XS_SENDMSG_FLAGS (MSG_DONTWAIT | MSG_NOSIGNAL) #define XS_SENDMSG_FLAGS (MSG_DONTWAIT | MSG_NOSIGNAL)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册