Commit 417ea9fe authored by Xiu Jianfeng's avatar Xiu Jianfeng Committed by John Johansen
Browse files

apparmor: Fix memleak in aa_simple_write_to_buffer()



When copy_from_user failed, the memory is freed by kvfree. however the
management struct and data blob are allocated independently, so only
kvfree(data) cause a memleak issue here. Use aa_put_loaddata(data) to
fix this issue.

Fixes: a6a52579 ("apparmor: split load data into management struct and data blob")
Signed-off-by: default avatarXiu Jianfeng <xiujianfeng@huawei.com>
Signed-off-by: default avatarJohn Johansen <john.johansen@canonical.com>
parent 11c3627e
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -403,7 +403,7 @@ static struct aa_loaddata *aa_simple_write_to_buffer(const char __user *userbuf,

	data->size = copy_size;
	if (copy_from_user(data->data, userbuf, copy_size)) {
		kvfree(data);
		aa_put_loaddata(data);
		return ERR_PTR(-EFAULT);
	}