Skip to content

util/mem: fix NULL dereference in nvme_realloc() on allocation failure#3178

Merged
igaw merged 1 commit intolinux-nvme:masterfrom
Micron-TPG-OSS:bugfix/nvme_realloc-fix
Mar 13, 2026
Merged

util/mem: fix NULL dereference in nvme_realloc() on allocation failure#3178
igaw merged 1 commit intolinux-nvme:masterfrom
Micron-TPG-OSS:bugfix/nvme_realloc-fix

Conversation

@jimmunn
Copy link
Copy Markdown
Contributor

@jimmunn jimmunn commented Mar 12, 2026

If nvme_alloc() fails and returns NULL, the subsequent memcpy() would dereference a NULL pointer, resulting in undefined behavior. Add a NULL check on the result of nvme_alloc() and return NULL early, consistent with standard realloc() semantics where the original pointer remains valid on failure.

If nvme_alloc() fails and returns NULL, the subsequent memcpy() would
dereference a NULL pointer, resulting in undefined behavior. Add a NULL
check on the result of nvme_alloc() and return NULL early, consistent
with standard realloc() semantics where the original pointer remains
valid on failure.

Signed-off-by: Jim Munn <[email protected]>
@igaw igaw merged commit 6c8e658 into linux-nvme:master Mar 13, 2026
26 checks passed
@igaw
Copy link
Copy Markdown
Collaborator

igaw commented Mar 13, 2026

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