Re: plugins/default: visit_rc() leaks file descriptor
Sean Young <[email protected]> Mon, 5 Sep 2022 15:32:55 +0100
| Newsgroups | gmane.comp.hardware.lirc |
|---|---|
| Message-ID | <YxYIl/[email protected]> |
Hi Thomas, On Sun, Sep 04, 2022 at 03:54:54PM +0200, Thomas Betker wrote: > Dear LIRC maintainers, > > visit_rc() opens /sys/class/rc/rc1/protocols O_RDONLY, but never closes it, > so the file stays open forever. [fd is overwritten by another O_WRONLY open > a few lines later; that one is closed correctly, though.] > > In my case (lirc-0.10.1 on openSUSE Leap 15.4, 'irw' running, 'lircd' > failing to open /dev/lirc1 due to permission issues), this means that > 'lircd' creates a new /sys/class/rc/rc1/protocols file descriptor every > second, sometimes resulting in hundreds of /proc/$PID/fd/ entries. > > Apparently, this was introduced by commit 06bd6d "plugins/default: Just > check lirc protocol if read-only access (#133)." on 17-Sep-2015. > > I would suggest closing fd right after reading it; please see my attached > patch (not tested). Patch applied. Thanks, Sean