Commit a692a86e authored by Cong Liu's avatar Cong Liu Committed by Hans de Goede

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: 10817f28 ("platform/x86/amd/pmf: Add capability to sideload of policy binary")
Reviewed-by: default avatarShyam Sundar S K <Shyam-sundar.S-k@amd.com>
Signed-off-by: default avatarCong Liu <liucong2@kylinos.cn>
Link: https://lore.kernel.org/r/20240124012939.6550-1-liucong2@kylinos.cnReviewed-by: default avatarHans de Goede <hdegoede@redhat.com>
Signed-off-by: default avatarHans de Goede <hdegoede@redhat.com>
parent cedecdba
...@@ -298,8 +298,10 @@ static ssize_t amd_pmf_get_pb_data(struct file *filp, const char __user *buf, ...@@ -298,8 +298,10 @@ static ssize_t amd_pmf_get_pb_data(struct file *filp, const char __user *buf,
if (!new_policy_buf) if (!new_policy_buf)
return -ENOMEM; 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; return -EFAULT;
}
kfree(dev->policy_buf); kfree(dev->policy_buf);
dev->policy_buf = new_policy_buf; dev->policy_buf = new_policy_buf;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment