]> git.ipfire.org Git - thirdparty/kernel/linux.git/commit
rtla/utils: Fix resource leak in set_comm_sched_attr()
authorWander Lairson Costa <wander@redhat.com>
Mon, 9 Mar 2026 19:46:30 +0000 (16:46 -0300)
committerTomas Glozar <tglozar@redhat.com>
Wed, 11 Mar 2026 14:29:50 +0000 (15:29 +0100)
commit5b6dc659ad792c72b3ff1be8039ae2945e030928
treed0612a4c07a98c6fedf0b0eb6c2b643882c4425a
parent47dd74f68c0c068fdd29cdf9fe1860a19209bc1f
rtla/utils: Fix resource leak in set_comm_sched_attr()

The set_comm_sched_attr() function opens the /proc directory via
opendir() but fails to call closedir() on its successful exit path.
If the function iterates through all processes without error, it
returns 0 directly, leaking the DIR stream pointer.

Fix this by refactoring the function to use a single exit path. A
retval variable is introduced to track the success or failure status.
All exit points now jump to a unified out label that calls closedir()
before the function returns, ensuring the resource is always freed.

Fixes: dada03db9bb19 ("rtla: Remove procps-ng dependency")
Signed-off-by: Wander Lairson Costa <wander@redhat.com>
Link: https://lore.kernel.org/r/20260309195040.1019085-18-wander@redhat.com
Signed-off-by: Tomas Glozar <tglozar@redhat.com>
tools/tracing/rtla/src/utils.c