]> www.infradead.org Git - users/sagi/nvme-cli.git/commitdiff
nvme-topology: fix returning invalid value in scan_subsystems()
authorMinwoo Im <minwoo.im.dev@gmail.com>
Sat, 23 Jan 2021 07:21:46 +0000 (16:21 +0900)
committerKeith Busch <kbusch@kernel.org>
Tue, 26 Jan 2021 21:03:05 +0000 (14:03 -0700)
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 <minwoo.im.dev@gmail.com>
nvme-topology.c

index 71371c5fff263413d520d75b4e52f26e7d141bd4..c0e2d5100b99712dcbc5dbc0cab93325971854a7 100644 (file)
@@ -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);