apparmor: Fix memleak in aa_simple_write_to_buffer()
authorXiu Jianfeng <xiujianfeng@huawei.com>
Tue, 14 Jun 2022 09:00:01 +0000 (17:00 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 25 Aug 2022 09:40:01 +0000 (11:40 +0200)
commitbf7ebebce2c25071c719fd8a2f1307e0c243c2d7
treeca46ed59929da9707a117fb8b125b7549166388f
parent64103ea357734b82384c925cba4758fdb909be0c
apparmor: Fix memleak in aa_simple_write_to_buffer()

commit 417ea9fe972d2654a268ad66e89c8fcae67017c3 upstream.

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: a6a52579e52b5 ("apparmor: split load data into management struct and data blob")
Signed-off-by: Xiu Jianfeng <xiujianfeng@huawei.com>
Signed-off-by: John Johansen <john.johansen@canonical.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
security/apparmor/apparmorfs.c