Thread (8 messages) 8 messages, 4 authors, 2025-09-03

Re: [PATCH v2] selftests: net: avoid memory leak

From: Jakub Kicinski <kuba@kernel.org>
Date: 2025-08-30 02:15:38
Also in: linux-kselftest, lkml

On Thu, 28 Aug 2025 10:02:10 +0800 Zongmin Zhou wrote:
quoted hunk ↗ jump to hunk
@@ -501,7 +502,8 @@ int main(int argc, char *argv[])
 	if (fd < 0) {
 		fprintf(stderr, "Can't open socket: %s\n", strerror(errno));
 		freeaddrinfo(ai);
Since you added the gotos now perhaps it'd be even better to remove
this freeaddrinfo() call here, and instead jump to a separate label...
quoted hunk ↗ jump to hunk
-		return ERN_RESOLVE;
+		err = ERN_RESOLVE;
+		goto err_free_buff;
 	}
 
 	if (opt.sock.proto == IPPROTO_ICMP) {
@@ -575,5 +577,7 @@ int main(int argc, char *argv[])
 err_out:
 	close(fd);
... added right here?
 	freeaddrinfo(ai);
+err_free_buff:
+	free(buf);
 	return err;
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help