libct: close child fds on prepareCgroupFD error

The (*setns).start is supposed to close child fds once the child has
started, or upon an error. Commit 5af4dd4e6 added a bug -- child fds
are not closed if prepareCgroupFD fails.

Fix by adding a missing call to closeChild.

I'm not sure how to write a good test case for it. Found when working
on PR 4928 (and tested in there).

Fixes: 5af4dd4e6
Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
This commit is contained in:
Kir Kolyshkin
2025-10-13 15:54:45 -07:00
parent 721d066576
commit 4e262509b8
+1
View File
@@ -357,6 +357,7 @@ func (p *setnsProcess) start() (retErr error) {
fd, err := p.prepareCgroupFD()
if err != nil {
p.comm.closeChild()
return err
}