Skip to content

Commit d6d478a

Browse files
committed
apparmor: Fix aa_label_build() error handling for failed merges
aa_label_merge() can return NULL for memory allocations failures make sure to handle and set the correct error in this case. Reported-by: Peng Hao <peng.hao2@zte.com.cn> Signed-off-by: John Johansen <john.johansen@canonical.com>
1 parent a1a0206 commit d6d478a

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

security/apparmor/domain.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1444,7 +1444,10 @@ int aa_change_profile(const char *fqname, int flags)
14441444
new = aa_label_merge(label, target, GFP_KERNEL);
14451445
if (IS_ERR_OR_NULL(new)) {
14461446
info = "failed to build target label";
1447-
error = PTR_ERR(new);
1447+
if (!new)
1448+
error = -ENOMEM;
1449+
else
1450+
error = PTR_ERR(new);
14481451
new = NULL;
14491452
perms.allow = 0;
14501453
goto audit;

0 commit comments

Comments
 (0)