criu icon indicating copy to clipboard operation
criu copied to clipboard

Util: close_safe must not clear fd on close() failure

Open shbhmexe opened this issue 1 month ago • 1 comments

This pull request addresses potential file descriptor leaks in the criu/util.c file by ensuring that file descriptors are properly closed if install_service_fd fails. This improves resource management and prevents leaking system resources.

Resource management improvements:

  • In both set_proc_fd and open_proc_sfd, added logic to close the duplicated or opened file descriptor if install_service_fd fails, preventing file descriptor leaks. [1] [2]

shbhmexe avatar Nov 21 '25 13:11 shbhmexe

Looking at the code I see that install_service_fd() already closes the fd if an error happened. Now it is closed twice.

The commit description also does not really match what happens in the code.

This feels like some coding assistant generated changes which look wrong to me.

adrianreber avatar Nov 26 '25 08:11 adrianreber