selinux: fix memleak in security_read_state_kernel()
authorXiu Jianfeng <xiujianfeng@huawei.com>
Mon, 13 Jun 2022 13:59:53 +0000 (21:59 +0800)
committerPaul Moore <paul@paul-moore.com>
Mon, 13 Jun 2022 23:31:53 +0000 (19:31 -0400)
commit73de1befcc53a7c68b0c5e76b9b5ac41c517760f
treed15d49fa0a234bb3ae70fe702fde5bb96ce86e27
parent8d6d51edcb79b0906288170df165c1b86e278218
selinux: fix memleak in security_read_state_kernel()

In this function, it directly returns the result of __security_read_policy
without freeing the allocated memory in *data, cause memory leak issue,
so free the memory if __security_read_policy failed.

Signed-off-by: Xiu Jianfeng <xiujianfeng@huawei.com>
[PM: subject line tweak]
Signed-off-by: Paul Moore <paul@paul-moore.com>
security/selinux/ss/services.c