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

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.cn


Reviewed-by: default avatarHans de Goede <hdegoede@redhat.com>
Signed-off-by: default avatarHans de Goede <hdegoede@redhat.com>
parent cedecdba
Loading
Loading
Loading
Loading
+3 −1
Original line number Diff line number Diff line
@@ -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;