Skip to content

Commit 690d722

Browse files
superm1ij-intel
authored andcommitted
drivers/platform/x86/amd: pmf: Check for invalid sideloaded Smart PC Policies
If a policy is passed into amd_pmf_get_pb_data() that causes the engine to fail to start there is a memory leak. Free the memory in this failure path. Fixes: 10817f2 ("platform/x86/amd/pmf: Add capability to sideload of policy binary") Signed-off-by: Mario Limonciello <mario.limonciello@amd.com> Link: https://lore.kernel.org/r/20250423132002.3984997-2-superm1@kernel.org Reviewed-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com> Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
1 parent 02c6e43 commit 690d722

1 file changed

Lines changed: 6 additions & 1 deletion

File tree

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

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -364,9 +364,14 @@ static ssize_t amd_pmf_get_pb_data(struct file *filp, const char __user *buf,
364364
amd_pmf_hex_dump_pb(dev);
365365
ret = amd_pmf_start_policy_engine(dev);
366366
if (ret < 0)
367-
return ret;
367+
goto cleanup;
368368

369369
return length;
370+
371+
cleanup:
372+
kfree(dev->policy_buf);
373+
dev->policy_buf = NULL;
374+
return ret;
370375
}
371376

372377
static const struct file_operations pb_fops = {

0 commit comments

Comments
 (0)