]> www.infradead.org Git - users/sagi/libnvme.git/commitdiff
tree: fix incorrect return value
authorCaleb Sander <csander@purestorage.com>
Thu, 30 Nov 2023 18:58:22 +0000 (11:58 -0700)
committerDaniel Wagner <wagi@monom.org>
Fri, 1 Dec 2023 09:46:56 +0000 (10:46 +0100)
nvme_scan_subsystem() accidentally sets errno = -EINVAL
if the matching subsystem is filtered out.
This errno value will be overwritten by the out_free path with -ret,
where ret is the length of the path string.
Set ret = -EINVAL instead, so errno will be set to EINVAL.
This matches the behavior in the case where a new subsystem is allocated
and fails the filter function.

Signed-off-by: Caleb Sander <csander@purestorage.com>
src/nvme/tree.c

index 3c8e75253c2eaae6718c28732406e4f5aa25f53e..4fb8357d88395e4c54b72ab0f467d43766c62285 100644 (file)
@@ -725,7 +725,7 @@ static int nvme_scan_subsystem(struct nvme_root *r, const char *name,
                        if (strcmp(_s->name, name))
                                continue;
                        if (!__nvme_scan_subsystem(r, _s, f, f_args)) {
-                               errno = -EINVAL;
+                               ret = -EINVAL;
                                goto out_free;
                        }
                        s = _s;