Skip to content

Commit

Permalink
drivers/platform/x86/amd: pmf: Check for invalid sideloaded Smart PC …
Browse files Browse the repository at this point in the history
…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>
  • Loading branch information
Mario Limonciello authored and Ilpo Järvinen committed Apr 29, 2025
1 parent 02c6e43 commit 690d722
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion drivers/platform/x86/amd/pmf/tee-if.c
Original file line number Diff line number Diff line change
Expand Up @@ -364,9 +364,14 @@ static ssize_t amd_pmf_get_pb_data(struct file *filp, const char __user *buf,
amd_pmf_hex_dump_pb(dev);
ret = amd_pmf_start_policy_engine(dev);
if (ret < 0)
return ret;
goto cleanup;

return length;

cleanup:
kfree(dev->policy_buf);
dev->policy_buf = NULL;
return ret;
}

static const struct file_operations pb_fops = {
Expand Down

0 comments on commit 690d722

Please sign in to comment.