Skip to content

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

Closed
jimmunn wants to merge 1 commit intolinux-nvme:masterfrom
Micron-TPG-OSS:bugfix/nvme_realloc-fix
Closed

util/mem: fix NULL dereference in nvme_realloc() on allocation failure#3175
jimmunn wants to merge 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]>
@jimmunn jimmunn force-pushed the bugfix/nvme_realloc-fix branch from 6099f9d to 24ced30 Compare March 12, 2026 17:28
@jimmunn
Copy link
Copy Markdown
Contributor Author

jimmunn commented Mar 12, 2026

Had wrong author info in commit. Closing and recreating.

@jimmunn jimmunn closed this Mar 12, 2026
@jimmunn jimmunn deleted the bugfix/nvme_realloc-fix branch March 12, 2026 17:42
@jimmunn jimmunn restored the bugfix/nvme_realloc-fix branch March 12, 2026 17:42
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