Skip to content

Commit a692a86

Browse files
Cong Liujwrdegoede
authored andcommitted
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: 10817f2 ("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>
1 parent cedecdb commit a692a86

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

drivers/platform/x86/amd/pmf/tee-if.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -298,8 +298,10 @@ static ssize_t amd_pmf_get_pb_data(struct file *filp, const char __user *buf,
298298
if (!new_policy_buf)
299299
return -ENOMEM;
300300

301-
if (copy_from_user(new_policy_buf, buf, length))
301+
if (copy_from_user(new_policy_buf, buf, length)) {
302+
kfree(new_policy_buf);
302303
return -EFAULT;
304+
}
303305

304306
kfree(dev->policy_buf);
305307
dev->policy_buf = new_policy_buf;

0 commit comments

Comments
 (0)