diff options
author | Chuck Lever <chuck.lever@oracle.com> | 2007-08-06 11:56:57 -0400 |
---|---|---|
committer | Trond Myklebust <Trond.Myklebust@netapp.com> | 2007-10-09 17:15:49 -0400 |
commit | 0c43b3d81cca46ab2469f8802f8bd68b49f1b2a5 (patch) | |
tree | b8233aba6352474e8e440a6228e97875aa2e7728 /net | |
parent | bda243df2f5beebce92bae22bc01960544783984 (diff) | |
download | op-kernel-dev-0c43b3d81cca46ab2469f8802f8bd68b49f1b2a5.zip op-kernel-dev-0c43b3d81cca46ab2469f8802f8bd68b49f1b2a5.tar.gz |
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: Chuck Lever <chuck.lever@oracle.com>
Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
Diffstat (limited to 'net')
-rw-r--r-- | net/sunrpc/xprtsock.c | 19 |
1 files changed, 12 insertions, 7 deletions
diff --git a/net/sunrpc/xprtsock.c b/net/sunrpc/xprtsock.c index 015f29e..b3f40b8 100644 --- a/net/sunrpc/xprtsock.c +++ b/net/sunrpc/xprtsock.c @@ -279,10 +279,14 @@ static void xs_format_peer_addresses(struct rpc_xprt *xprt) } xprt->address_strings[RPC_DISPLAY_PORT] = buf; - if (xprt->prot == IPPROTO_UDP) - xprt->address_strings[RPC_DISPLAY_PROTO] = "udp"; - else - xprt->address_strings[RPC_DISPLAY_PROTO] = "tcp"; + buf = kzalloc(8, GFP_KERNEL); + if (buf) { + if (xprt->prot == IPPROTO_UDP) + snprintf(buf, 8, "udp"); + else + snprintf(buf, 8, "tcp"); + } + xprt->address_strings[RPC_DISPLAY_PROTO] = buf; buf = kzalloc(48, GFP_KERNEL); if (buf) { @@ -296,9 +300,10 @@ static void xs_format_peer_addresses(struct rpc_xprt *xprt) static void xs_free_peer_addresses(struct rpc_xprt *xprt) { - kfree(xprt->address_strings[RPC_DISPLAY_ADDR]); - kfree(xprt->address_strings[RPC_DISPLAY_PORT]); - kfree(xprt->address_strings[RPC_DISPLAY_ALL]); + int i; + + for (i = 0; i < RPC_DISPLAY_MAX; i++) + kfree(xprt->address_strings[i]); } #define XS_SENDMSG_FLAGS (MSG_DONTWAIT | MSG_NOSIGNAL) |