Skip to content

nvme: sanitize call to strerror()#3078

Merged
igaw merged 2 commits intolinux-nvme:masterfrom
martin-gpy:sanitize_strerror
Feb 10, 2026
Merged

nvme: sanitize call to strerror()#3078
igaw merged 2 commits intolinux-nvme:masterfrom
martin-gpy:sanitize_strerror

Conversation

@martin-gpy
Copy link
Copy Markdown
Contributor

Avoid passing a negative int to strerror() for cleaner handling.

Valgrind revealed a mem leak while running nvme list-subsys -vv:

==2486== 18 bytes in 1 blocks are still reachable in loss record 1 of 1
==2486==    at 0x4841984: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==2486==    by 0x4956037: __vasprintf_internal (in /lib64/libc.so.6)
==2486==    by 0x49F73AE: __asprintf_chk (in /lib64/libc.so.6)
==2486==    by 0x49796FB: strerror_l (in /lib64/libc.so.6)
==2486==    by 0x488A4AF: nvme_scan_topology (tree.c:317)
==2486==    by 0x42E3BC: list_subsys (nvme.c:3499)
==2486==    by 0x445F88: handle_plugin (plugin.c:190)
==2486==    by 0x407620: main (nvme.c:11119)

Fix this by ensuring an appropriate value is passed to strerror().

Signed-off-by: Martin George <[email protected]>
Comment thread libnvme/src/nvme/tree.c Outdated
Passing a negative int to strerror() may lead to undefined behavior
and also result in a mem leak. Fix this by ensuring an appropriate
value is passed instead.

Signed-off-by: Martin George <[email protected]>
@igaw igaw merged commit 9f3f0f5 into linux-nvme:master Feb 10, 2026
16 of 19 checks passed
@igaw
Copy link
Copy Markdown
Collaborator

igaw commented Feb 10, 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