[lxc/lxc] aebd80: Don't leak an open fd

0 views
Skip to first unread message

Stéphane Graber

unread,
Apr 28, 2026, 10:12:21 AMApr 28
to lxc-...@lists.linuxcontainers.org
Branch: refs/heads/main
Home: https://github.com/lxc/lxc
Commit: aebd808dac4ab14dce6ff05ece860c6d4f400945
https://github.com/lxc/lxc/commit/aebd808dac4ab14dce6ff05ece860c6d4f400945
Author: Serge Hallyn <se...@hallyn.com>
Date: 2026-04-28 (Tue, 28 Apr 2026)

Changed paths:
M src/lxc/storage/storage.c

Log Message:
-----------
Don't leak an open fd

The dfd_idmapped was being dup'd, but not freed.

If we ever change it so that storage_put closes the dfd_idmapped
fd, then we'll want to un-do this. For now, this is a kludgy way
to avoid leaking the open fd, but should work.

The new_rootfs->dfd_idmapped gets dup'd from
c->lxc_conf->rootfs.dfd_idmapped. new_rootfs eventually gets
assigned to new->rootfs (where new is a struct storage, usually
called 'bdev'). From here there are error paths which free the
bdev and return NULL, and a success path that returns bdev. But
neither the error path nor the caller do anything really with the
bdev, and storage_put() doesn't close that fd.

So close the dfd_idmapped in both paths.

Coverity id: 1641426

Signed-off-by: Serge Hallyn <se...@hallyn.com>


Commit: f5c6aadbd3f9e429fa3ee172053403ef72a3a3f8
https://github.com/lxc/lxc/commit/f5c6aadbd3f9e429fa3ee172053403ef72a3a3f8
Author: Stéphane Graber <stgr...@stgraber.org>
Date: 2026-04-28 (Tue, 28 Apr 2026)

Changed paths:
M src/lxc/storage/storage.c

Log Message:
-----------
Merge pull request #4677 from hallyn/2026-04-28/leakfd

Don't leak an open fd


Compare: https://github.com/lxc/lxc/compare/af2f96b99138...f5c6aadbd3f9

To unsubscribe from these emails, change your notification settings at https://github.com/lxc/lxc/settings/notifications
Reply all
Reply to author
Forward
0 new messages