Skip to content

Commit 19b181e

Browse files
aescolarkartben
authored andcommitted
drivers/input/linux_evdev: Close input file on exec
If the process does an exec() (or fork, or..) all descriptors are kept open by default, unless O_CLOEXEC is set when opening them. This is usefull for stdin/out/err so that new process is connected to them, but it is very rare for it to be usefull for any other descriptor. In general this leads to descriptors being kept open unnecessarily, which either will block other process from getting them (for example if the child survives the parent but it does something else). Or for a "leak" which unnecessarily uses descriptors and memory in the child process. Let's ensure we do not leak it for this component as we do not need it. Signed-off-by: Alberto Escolar Piedras <[email protected]>
1 parent e5d6e0c commit 19b181e

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

drivers/input/linux_evdev_bottom.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ int linux_evdev_open(const char *path)
4242
{
4343
int fd;
4444

45-
fd = open(path, O_RDONLY | O_NONBLOCK);
45+
fd = open(path, O_RDONLY | O_NONBLOCK | O_CLOEXEC);
4646
if (fd < 0) {
4747
nsi_print_error_and_exit(
4848
"Failed to open the evdev device %s: %s\n",

0 commit comments

Comments
 (0)