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: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <0fcefad8-540f-487e-b5b6-b78009bf5d9b@linuxfoundation.org>
Date: Wed, 10 Jul 2024 09:48:42 -0600
From: Shuah Khan <skhan@...uxfoundation.org>
To: Zhu Jun <zhujun2@...s.chinamobile.com>, shuah@...nel.org
Cc: chenxiang66@...ilicon.com, iommu@...ts.linux.dev,
 linux-kselftest@...r.kernel.org, linux-kernel@...r.kernel.org,
 Shuah Khan <skhan@...uxfoundation.org>
Subject: Re: [PATCH] selftests/dma:Fix a resource leak

On 7/10/24 00:30, Zhu Jun wrote:
> The opened file should be closed in main(), otherwise resource
> leak will occur that this problem was discovered by reading code
> 
> Signed-off-by: Zhu Jun <zhujun2@...s.chinamobile.com>
> ---
>   tools/testing/selftests/dma/dma_map_benchmark.c | 3 +++
>   1 file changed, 3 insertions(+)
> 
> diff --git a/tools/testing/selftests/dma/dma_map_benchmark.c b/tools/testing/selftests/dma/dma_map_benchmark.c
> index 5c997f17fcbd..3fcea00961c0 100644
> --- a/tools/testing/selftests/dma/dma_map_benchmark.c
> +++ b/tools/testing/selftests/dma/dma_map_benchmark.c
> @@ -114,6 +114,7 @@ int main(int argc, char **argv)
>   	map.granule = granule;
>   
>   	if (ioctl(fd, cmd, &map)) {
> +		close(fd);
>   		perror("ioctl");
>   		exit(1);
>   	}
> @@ -125,5 +126,7 @@ int main(int argc, char **argv)
>   	printf("average unmap latency(us):%.1f standard deviation:%.1f\n",
>   			map.avg_unmap_100ns/10.0, map.unmap_stddev/10.0);
>   
> +	close(fd);
> +
>   	return 0;
>   }

Files get closed when this process exits. There is no need
to make this change.

thanks,
-- Shuah

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ