lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20250827161230.GB10519@horms.kernel.org>
Date: Wed, 27 Aug 2025 17:12:30 +0100
From: Simon Horman <horms@...nel.org>
To: Zongmin Zhou <min_halo@....com>
Cc: davem@...emloft.net, edumazet@...gle.com, kuba@...nel.org,
	pabeni@...hat.com, shuah@...nel.org, netdev@...r.kernel.org,
	linux-kselftest@...r.kernel.org, linux-kernel@...r.kernel.org,
	Zongmin Zhou <zhouzongmin@...inos.cn>
Subject: Re: [PATCH] selftests: net: avoid memory leak

On Tue, Aug 26, 2025 at 11:15:40AM +0800, Zongmin Zhou wrote:
> From: Zongmin Zhou <zhouzongmin@...inos.cn>
> 
> The buffer be used without free,fix it to avoid memory leak.

I'm assuming this is a short-lived user-space program.
And any memory is freed when it exits.
So I'm unsure about the value of this change.

> 
> Signed-off-by: Zongmin Zhou <zhouzongmin@...inos.cn>
> ---
>  tools/testing/selftests/net/cmsg_sender.c | 3 +++
>  1 file changed, 3 insertions(+)
> 
> diff --git a/tools/testing/selftests/net/cmsg_sender.c b/tools/testing/selftests/net/cmsg_sender.c
> index a825e628aee7..5358aa09ecb9 100644
> --- a/tools/testing/selftests/net/cmsg_sender.c
> +++ b/tools/testing/selftests/net/cmsg_sender.c
> @@ -491,6 +491,7 @@ int main(int argc, char *argv[])
>  	if (err) {
>  		fprintf(stderr, "Can't resolve address [%s]:%s\n",
>  			opt.host, opt.service);
> +		free(buf);
>  		return ERN_SOCK_CREATE;
>  	}
>  
> @@ -501,6 +502,7 @@ int main(int argc, char *argv[])
>  	if (fd < 0) {
>  		fprintf(stderr, "Can't open socket: %s\n", strerror(errno));
>  		freeaddrinfo(ai);
> +		free(buf);
>  		return ERN_RESOLVE;
>  	}
>  
> @@ -575,5 +577,6 @@ int main(int argc, char *argv[])
>  err_out:
>  	close(fd);
>  	freeaddrinfo(ai);

I think it would be nicer to add another label here, say err_free_buff,
and then use it in the previous two hunks.

> +	free(buf);
>  	return err;
>  }
> -- 
> 2.34.1
> 

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ