Skip to content

nbft-plugin: fix resource leak in show_nbft() - #3665

Merged
igaw merged 1 commit into
linux-nvme:masterfrom
sahmed-ibm:fix-nbft-plugin-resrc-leak_head
Jul 28, 2026
Merged

nbft-plugin: fix resource leak in show_nbft()#3665
igaw merged 1 commit into
linux-nvme:masterfrom
sahmed-ibm:fix-nbft-plugin-resrc-leak_head

Conversation

@sahmed-ibm

Copy link
Copy Markdown
Contributor

The show_nbft() function calls libnvmf_nbft_read_files() to build a linked list of NBFT file entries pointed to by head. The call to libnvmf_nbft_free() to release that list is guarded by the condition that ret is zero and head is non-NULL.

If libnvmf_nbft_read_files() partially populates head before returning an error, the already-allocated entries are never freed, resulting in a resource leak on the error path.

Move libnvmf_nbft_free() outside the conditional block so head is always freed. libnvmf_nbft_free() already handles a NULL head safely, so the unconditional call is correct in all cases.

The show_nbft() function calls libnvmf_nbft_read_files() to build
a linked list of NBFT file entries pointed to by head. The call
to libnvmf_nbft_free() to release that list is guarded by the
condition that ret is zero and head is non-NULL.

If libnvmf_nbft_read_files() partially populates head before
returning an error, the already-allocated entries are never freed,
resulting in a resource leak on the error path.

Move libnvmf_nbft_free() outside the conditional block so head
is always freed. libnvmf_nbft_free() already handles a NULL head
safely, so the unconditional call is correct in all cases.

Signed-off-by: Sarah Ahmed <sarah.ahmed@ibm.com>
@igaw
igaw merged commit 08c3fe8 into linux-nvme:master Jul 28, 2026
32 checks passed
@igaw

igaw commented Jul 28, 2026

Copy link
Copy Markdown
Collaborator

Thanks!

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