summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCong Liu <liucong2@kylinos.cn>2024-01-24 09:29:38 +0800
committerHans de Goede <hdegoede@redhat.com>2024-01-26 20:12:16 +0100
commita692a86efe97fe0aba7cb15f38cbce866c080689 (patch)
tree57edee06f1e1bde243a7a7af2fdf2afd98ee4d42
parentcedecdba60f4a42a8562574119f317ed0c674b5a (diff)
platform/x86/amd/pmf: Fix memory leak in amd_pmf_get_pb_data()
amd_pmf_get_pb_data() will allocate memory for the policy buffer, but does not free it if copy_from_user() fails. This leads to a memory leak. Fixes: 10817f28e533 ("platform/x86/amd/pmf: Add capability to sideload of policy binary") Reviewed-by: Shyam Sundar S K <Shyam-sundar.S-k@amd.com> Signed-off-by: Cong Liu <liucong2@kylinos.cn> Link: https://lore.kernel.org/r/20240124012939.6550-1-liucong2@kylinos.cn Reviewed-by: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Hans de Goede <hdegoede@redhat.com>
-rw-r--r--drivers/platform/x86/amd/pmf/tee-if.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/drivers/platform/x86/amd/pmf/tee-if.c b/drivers/platform/x86/amd/pmf/tee-if.c
index 502ce93d5cdd..f8c0177afb0d 100644
--- a/drivers/platform/x86/amd/pmf/tee-if.c
+++ b/drivers/platform/x86/amd/pmf/tee-if.c
@@ -298,8 +298,10 @@ static ssize_t amd_pmf_get_pb_data(struct file *filp, const char __user *buf,
if (!new_policy_buf)
return -ENOMEM;
- if (copy_from_user(new_policy_buf, buf, length))
+ if (copy_from_user(new_policy_buf, buf, length)) {
+ kfree(new_policy_buf);
return -EFAULT;
+ }
kfree(dev->policy_buf);
dev->policy_buf = new_policy_buf;