From: John Johansen Date: Thu, 24 Jan 2019 21:53:05 +0000 (-0800) Subject: apparmor: Fix aa_label_build() error handling for failed merges X-Git-Url: http://git.cdn.openwrt.org/?a=commitdiff_plain;h=d6d478aee003e19ef90321176552a8ad2929a47f;p=openwrt%2Fstaging%2Fblogic.git 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 Signed-off-by: John Johansen --- diff --git a/security/apparmor/domain.c b/security/apparmor/domain.c index 08c88de0ffda..11975ec8d566 100644 --- a/security/apparmor/domain.c +++ b/security/apparmor/domain.c @@ -1444,7 +1444,10 @@ check: new = aa_label_merge(label, target, GFP_KERNEL); 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;