From: Caleb Sander Date: Thu, 30 Nov 2023 18:58:22 +0000 (-0700) Subject: tree: fix incorrect return value X-Git-Tag: v1.7~19 X-Git-Url: https://www.infradead.org/git/?a=commitdiff_plain;h=33ea970f6ce2de0f3ea6c77286522d981e998dbe;p=users%2Fsagi%2Flibnvme.git 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 --- 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;