Re: [PATCH] selftests/memfd: fix a memleak

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 2023-11-15 00:45, zhujun2 wrote:
The memory allocated within a function should be released
before the function return,otherwise memleak will occur.

[...]

--- a/tools/testing/selftests/memfd/fuse_test.c
+++ b/tools/testing/selftests/memfd/fuse_test.c
@@ -205,6 +205,7 @@ static pid_t spawn_sealing_thread(void)
  	stack = malloc(STACK_SIZE);
  	if (!stack) {
  		printf("malloc(STACK_SIZE) failed: %m\n");
+		free(stack);
  		abort();

Freeing process memory immediately before an abort(3) seems rather
pointless, because the whole process is going away anyway. It's like
tidying up your house right before it is scheduled to be bulldozed
away to make room for a new highway. :-)

Thanks,

Mathieu

--
Mathieu Desnoyers
EfficiOS Inc.
https://www.efficios.com





[Index of Archives]     [Linux Wireless]     [Linux Kernel]     [ATH6KL]     [Linux Bluetooth]     [Linux Netdev]     [Kernel Newbies]     [Share Photos]     [IDE]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux ATA RAID]     [Samba]     [Device Mapper]

  Powered by Linux