Skip to content

netapp-nvme: fix uninitialized pointer in netapp_smdevices() - #3651

Open
sahmed-ibm wants to merge 1 commit into
linux-nvme:masterfrom
sahmed-ibm:fix-netapp-nvme-uninitialized-ptr-read_devices
Open

netapp-nvme: fix uninitialized pointer in netapp_smdevices()#3651
sahmed-ibm wants to merge 1 commit into
linux-nvme:masterfrom
sahmed-ibm:fix-netapp-nvme-uninitialized-ptr-read_devices

Conversation

@sahmed-ibm

Copy link
Copy Markdown
Contributor

The netapp_smdevices() function declares the devices pointer used to receive the scandir() output, but does not initialize it before passing its address to scandir().

If execution reaches the scandir() call with devices holding an indeterminate stack value, the behavior is undefined.

Initialize devices to NULL so it holds a defined value before scandir() writes to it through the pointer.

The netapp_smdevices() function declares the devices pointer used
to receive the scandir() output, but does not initialize it before
passing its address to scandir().

If execution reaches the scandir() call with devices holding an
indeterminate stack value, the behavior is undefined.

Initialize devices to NULL so it holds a defined value before
scandir() writes to it through the pointer.

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

igaw commented Jul 28, 2026

Copy link
Copy Markdown
Collaborator

This commit message is wrong.

The namelist parameter is an output parameter. On success, scandir() allocates an array and stores its address in *namelist. On failure, it returns -1. There is no requirement in POSIX that *namelist be initialized before the call. This is just to shut up the analyzer.

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