]> www.infradead.org Git - users/hch/nvme-cli.git/commit
Check return value of scandir
authorSzczerbik, Przemyslaw <przemyslawx.szczerbik@intel.com>
Fri, 27 Sep 2019 06:39:50 +0000 (07:39 +0100)
committerSzczerbik, Przemyslaw <przemyslawx.szczerbik@intel.com>
Fri, 27 Sep 2019 06:39:50 +0000 (07:39 +0100)
commit0436d4a1f28523f8c48adc18956857e69eaf1b8f
tree846f6184ac5a9d938479e759e8501a7c7a568a77
parent5c1ab098694b13d752296eab64decac3b51829dd
Check return value of scandir

On error, scandir returns -1 and does not allocate memory
for namelist array. In some places in the code return value
of scandir call is not checked. This causes nvme-cli to
attempt to free() an uninitialized pointer, which subsequently
leads to segmentation fault.

To address this issue, check return value of scandir calls
throughout the code.

Signed-off-by: Szczerbik, Przemyslaw <przemyslawx.szczerbik@intel.com>
nvme-topology.c