lkml.org 
[lkml]   [2023]   [Nov]   [9]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH] tools/gpio: prevent resource leak
On Thu, Nov 09, 2023 at 04:54:19PM +0800, heminhong wrote:
> In the main() function, the open() function is used to open the file.
> When the file is successfully opened, fd is used to interact with the file,
> but the fd is not closed, it will cause resource leak.
>

All open files are automatically closed when a process exits.
That includes both those returned by open() and by the GPIO ioctls.
So explicitly closing them here before exiting is redundant.

Cheers,
Kent.

\
 
 \ /
  Last update: 2023-11-20 13:54    [W:1.655 / U:2.400 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site