From: Minwoo Im Date: Sat, 23 Jan 2021 07:21:46 +0000 (+0900) Subject: nvme-topology: fix returning invalid value in scan_subsystems() X-Git-Tag: v1.14~119^2^2~1 X-Git-Url: https://www.infradead.org/git/?a=commitdiff_plain;h=9f9e9352b6c2629d68aa9e8f5046ca9a6d6efed2;p=users%2Fsagi%2Fnvme-cli.git nvme-topology: fix returning invalid value in scan_subsystems() Let's say we have multiple three subsystems in the system. If we run a simple 'nvme list' command, then scan_subsystems() will never set the 'ret' value which is a local variable. This should be initialized to a initial value to avoid invalid value returning. This patch fixes returning invalid value from the scan_subsystems() in case of multi-subsystems found. Signed-off-by: Minwoo Im --- diff --git a/nvme-topology.c b/nvme-topology.c index 71371c5f..c0e2d510 100644 --- a/nvme-topology.c +++ b/nvme-topology.c @@ -554,7 +554,7 @@ int scan_subsystems(struct nvme_topology *t, const char *subsysnqn, { struct nvme_subsystem *s; struct dirent **subsys; - int ret, i, j = 0; + int ret = 0, i, j = 0; t->nr_subsystems = scandir(subsys_dir, &subsys, scan_subsys_filter, alphasort);