Skip to content

Commit 52e8c38

Browse files
tyhicksjrjohansen
authored andcommitted
apparmor: Fix memory leak of rule on error exit path
Currently on the error exit path the allocated rule is not free'd causing a memory leak. Fix this by calling aa_audit_rule_free(). Detected by CoverityScan, CID#1468966 ("Resource leaks") Fixes: cb740f5 ("apparmor: modify audit rule support to support profile stacks") Signed-off-by: Tyler Hicks <tyhicks@canonical.com> Signed-off-by: John Johansen <john.johansen@canonical.com>
1 parent 2ab47da commit 52e8c38

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

security/apparmor/audit.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -200,10 +200,12 @@ int aa_audit_rule_init(u32 field, u32 op, char *rulestr, void **vrule)
200200
/* Currently rules are treated as coming from the root ns */
201201
rule->label = aa_label_parse(&root_ns->unconfined->label, rulestr,
202202
GFP_KERNEL, true, false);
203-
if (IS_ERR(rule->label))
203+
if (IS_ERR(rule->label)) {
204+
aa_audit_rule_free(rule);
204205
return PTR_ERR(rule->label);
205-
*vrule = rule;
206+
}
206207

208+
*vrule = rule;
207209
return 0;
208210
}
209211

0 commit comments

Comments
 (0)