diff --git a/gck-rpc-dispatch.c b/gck-rpc-dispatch.c
index f1b479800f93d74e916357e06c5271587f614155..da802c133a013718e634c58d145467389e014fca 100644
--- a/gck-rpc-dispatch.c
+++ b/gck-rpc-dispatch.c
@@ -2346,6 +2346,8 @@ int gck_rpc_layer_initialize(const char *prefix, CK_FUNCTION_LIST_PTR module)
 
 		snprintf(pkcs11_socket_path, sizeof(pkcs11_socket_path),
 			 "%s", prefix);
+
+		free(ip);
 	} else {
 		snprintf(pkcs11_socket_path, sizeof(pkcs11_socket_path),
 			 "%s/socket.pkcs11", prefix);