Skip to content

xen-pciback: free a device's config fields before its dev_data - #88

Merged
kdaula merged 1 commit into
edera/mainlinefrom
kavi/cor-208-pciback-release-leak
Nov 5, 2026
Merged

kdaula merged 1 commit into
edera/mainlinefrom
kavi/cor-208-pciback-release-leak

Conversation

@kdaula

@kdaula kdaula commented Nov 5, 2026 •

Copy link
Copy Markdown

Releasing a device from pciback leaks its virtual config space fields, about 25 small allocations per device. pcistub_device_release() frees dev_data and clears drvdata before calling xen_pcibk_config_free_dyn_fields() and xen_pcibk_config_free_dev(). Both find the fields through drvdata, so they free nothing, and kmemleak reports the fields after xl pci-assignable-remove.

This frees the fields first.

Tested on edera/6.18-lts by passing a device through to a PV zone and releasing it, after which kmemleak no longer reports the fields.

COR-208

pcistub_device_release() frees dev_data and clears drvdata before
calling xen_pcibk_config_free_dyn_fields() and
xen_pcibk_config_free_dev(). Both look the fields up through drvdata,
find NULL and return, so every release from pciback leaks the device's
config field entries and their data. kmemleak reports them after the
device is released.

Free the fields first.

Fixes: cd9db80 ("xen/pciback: Support pci_reset_function, aka FLR or D3 support.")
Signed-off-by: Kavi <kavi@edera.dev>
@kdaula
kdaula merged commit 7d91f39 into edera/mainline Nov 5, 2026
3 checks passed
@kdaula
kdaula deleted the kavi/cor-208-pciback-release-leak branch November 5, 2026 16:21
@github-actions

github-actions Bot commented Nov 5, 2026

Copy link
Copy Markdown

Backport to edera/6.18-lts: proposed in #92

Checks and builds passed.

Run log

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants