gssd: fix memory leak in gssd_free_client

"zhangjian (CG)" <[email protected]>
Newsgroups gmane.linux.nfs
Message-ID <[email protected]>
clp->servername is always not null, so upcall_* is never free.

Signed-off-by: zhangjian <[email protected]>
---
 utils/gssd/gssd.c | 24 ++++++++++++++----------
 1 file changed, 14 insertions(+), 10 deletions(-)

diff --git a/utils/gssd/gssd.c b/utils/gssd/gssd.c
index 1c901991..bad92321 100644
--- a/utils/gssd/gssd.c
+++ b/utils/gssd/gssd.c
@@ -360,6 +360,10 @@ gssd_read_service_info(int dirfd, struct clnt_info *clp)
 	clp->prog = program;
 	clp->vers = version;
 	clp->protocol = protoname;
+	clp->upcall_address = NULL;
+	clp->upcall_port = NULL;
+	clp->upcall_protoname = NULL;
+	clp->upcall_service = NULL;
 
 	goto out;
 
@@ -414,16 +418,16 @@ gssd_free_client(struct clnt_info *clp)
 	free(clp->servicename);
 	free(clp->servername);
 	free(clp->protocol);
-	if (!clp->servername) {
-		if (clp->upcall_address)
-			free(clp->upcall_address);
-		if (clp->upcall_port)
-			free(clp->upcall_port);
-		if (clp->upcall_protoname)
-			free(clp->upcall_protoname);
-		if (clp->upcall_service)
-			free(clp->upcall_service);
-	}
+
+	if (clp->upcall_address)
+		free(clp->upcall_address);
+	if (clp->upcall_port)
+		free(clp->upcall_port);
+	if (clp->upcall_protoname)
+		free(clp->upcall_protoname);
+	if (clp->upcall_service)
+		free(clp->upcall_service);
+
 	free(clp);
 }
 
-- 
2.33.0
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.