Skip to content

tree: replace strdup with xstrdup in nvme_alloc_subsystem()#3518

Merged
igaw merged 1 commit into
linux-nvme:masterfrom
sahmed-ibm:fix-null-strdup-subsysnqn
Jun 29, 2026
Merged

tree: replace strdup with xstrdup in nvme_alloc_subsystem()#3518
igaw merged 1 commit into
linux-nvme:masterfrom
sahmed-ibm:fix-null-strdup-subsysnqn

Conversation

@sahmed-ibm

Copy link
Copy Markdown
Contributor

Replace strdup() with xstrdup() when duplicating the subsystem NQN.
Unlike strdup(), xstrdup() safely returns NULL when passed a NULL
pointer, avoiding undefined behavior if subsysnqn is NULL.

Also check the return value from xstrdup() and bail out early if
duplicating the subsystem NQN fails, either because the input pointer
is NULL or because memory allocation was unsuccessful.

This issue was reported by the clang static analyzer.

Signed-off-by: Sarah Ahmed sarah.ahmed@ibm.com

@igaw

igaw commented Jun 29, 2026

Copy link
Copy Markdown
Collaborator

Could you merge the two patches into one. Thanks!

Replace strdup() with xstrdup() when duplicating the subsystem NQN.
Unlike strdup(), xstrdup() safely returns NULL when passed a NULL
pointer, avoiding undefined behavior if subsysnqn is NULL.

Also check the return value from xstrdup() and bail out early if
duplicating the subsystem NQN fails, either because the input pointer
is NULL or because memory allocation was unsuccessful.

This issue was reported by the clang static analyzer.

Signed-off-by: Sarah Ahmed <sarah.ahmed@ibm.com>
@sahmed-ibm sahmed-ibm force-pushed the fix-null-strdup-subsysnqn branch from 04f1951 to d4f425a Compare June 29, 2026 16:51
@sahmed-ibm

Copy link
Copy Markdown
Contributor Author

Sure!

@igaw igaw merged commit 7e9b738 into linux-nvme:master Jun 29, 2026
32 checks passed
@igaw

igaw commented Jun 29, 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