apparmor: report a label allocation failure as -ENOMEM

aa_label_strn_parse() returns -ENOENT for every failure, so a caller
cannot tell "no such profile" from "could not allocate a label".

Report an allocation failure as -ENOMEM.

Fixes: f1bd904175 ("apparmor: add the base fns() for domain labels")
Signed-off-by: Maxime Bélair <maxime.belair@canonical.com>
Signed-off-by: John Johansen <john.johansen@canonical.com>
This commit is contained in:
Maxime Bélair 2026-08-19 10:00:19 +01:00 committed by John Johansen
parent f7bd6285ff
commit 07aee062c6

View File

@ -1954,12 +1954,18 @@ struct aa_label *aa_label_strn_parse(struct aa_label *base, const char *str,
goto out;
}
if (create)
if (create) {
label = aa_vec_find_or_create_label(vec, len, gfp);
else
if (!label) {
/* not absence: creating only fails on allocation */
label = ERR_PTR(-ENOMEM);
goto out;
}
} else {
label = vec_find(vec, len);
if (!label)
goto fail;
if (!label)
goto fail;
}
out:
/* use adjusted len from after vec_unique, not original */