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 <[email protected]> Link: https://lore.kernel.org/r/[email protected] Reviewed-by: Ilpo Järvinen <[email protected]> Signed-off-by: Ilpo Järvinen <[email protected]>
1 parent 02c6e43 commit 690d722

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

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)