apparmor: add missing failure check in compute_xmatch_perms

[ Upstream commit 6600e9f692 ]

Add check for failure to allocate the permission table.

Fixes: caa9f579ca ("apparmor: isolate policy backwards compatibility to its own file")
Signed-off-by: John Johansen <john.johansen@canonical.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
This commit is contained in:
John Johansen 2023-04-14 00:24:47 -07:00 committed by Greg Kroah-Hartman
parent 543731db01
commit 33b1fe578f
1 changed files with 2 additions and 0 deletions

View File

@ -179,6 +179,8 @@ static struct aa_perms *compute_xmatch_perms(struct aa_dfa *xmatch)
state_count = xmatch->tables[YYTD_ID_BASE]->td_lolen;
/* DFAs are restricted from having a state_count of less than 2 */
perms = kvcalloc(state_count, sizeof(struct aa_perms), GFP_KERNEL);
if (!perms)
return NULL;
/* zero init so skip the trap state (state == 0) */
for (state = 1; state < state_count; state++)