Commit 865c798a authored by John Johansen's avatar John Johansen Committed by Greg Kroah-Hartman

apparmor: Fix aa_label_build() error handling for failed merges

[ Upstream commit d6d478ae ]

aa_label_merge() can return NULL for memory allocations failures
make sure to handle and set the correct error in this case.
Reported-by: default avatarPeng Hao <peng.hao2@zte.com.cn>
Signed-off-by: default avatarJohn Johansen <john.johansen@canonical.com>
Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
parent c72b4dcd
......@@ -1260,7 +1260,10 @@ int aa_change_profile(const char *fqname, int flags)
aa_get_label(&profile->label));
if (IS_ERR_OR_NULL(new)) {
info = "failed to build target label";
error = PTR_ERR(new);
if (!new)
error = -ENOMEM;
else
error = PTR_ERR(new);
new = NULL;
perms.allow = 0;
goto audit;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment