apparmor: fix a memleak in multi_transaction_new()
authorGaosheng Cui <cuigaosheng1@huawei.com>
Tue, 23 Aug 2022 01:15:03 +0000 (09:15 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sat, 31 Dec 2022 12:32:29 +0000 (13:32 +0100)
commit3d27a436e294ac5d7a51bd5348ca63a42a468b35
tree51a5e06c3cb4d82b7c6d9d7f8aff04ee3c8f04a6
parent14ed46a13aba42a6ddd85de6f6274090df3586a5
apparmor: fix a memleak in multi_transaction_new()

[ Upstream commit c73275cf6834787ca090317f1d20dbfa3b7f05aa ]

In multi_transaction_new(), the variable t is not freed or passed out
on the failure of copy_from_user(t->data, buf, size), which could lead
to a memleak.

Fix this bug by adding a put_multi_transaction(t) in the error path.

Fixes: 1dea3b41e84c5 ("apparmor: speed up transactional queries")
Signed-off-by: Gaosheng Cui <cuigaosheng1@huawei.com>
Signed-off-by: John Johansen <john.johansen@canonical.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
security/apparmor/apparmorfs.c