[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAHp75Vd5Ea_yFb7tEQw5ZBr90CcETa-_BsbfpfFshFx8ddZqQA@mail.gmail.com>
Date: Thu, 9 Nov 2023 15:53:45 +0200
From: Andy Shevchenko <andy.shevchenko@...il.com>
To: Kent Gibson <warthog618@...il.com>
Cc: heminhong <heminhong@...inos.cn>, linus.walleij@...aro.org,
brgl@...ev.pl, andy@...nel.org, linux-gpio@...r.kernel.org,
linux-kernel@...r.kernel.org
Subject: Re: [PATCH] tools/gpio: prevent resource leak
On Thu, Nov 9, 2023 at 2:36 PM Kent Gibson <warthog618@...il.com> wrote:
>
> 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.
I would argue that this is a good practice for GPIO cases.
More the GPIOs we have, the more line handles we can get, then default
MAX open FD limit may occur. The best is to combine both.
--
With Best Regards,
Andy Shevchenko
Powered by blists - more mailing lists