From 33ea970f6ce2de0f3ea6c77286522d981e998dbe Mon Sep 17 00:00:00 2001 From: Caleb Sander Date: Thu, 30 Nov 2023 11:58:22 -0700 Subject: [PATCH] tree: fix incorrect return value 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 --- src/nvme/tree.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/nvme/tree.c b/src/nvme/tree.c index 3c8e7525..4fb8357d 100644 --- a/src/nvme/tree.c +++ b/src/nvme/tree.c @@ -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; -- 2.50.1