diff options
| author | Ingo Molnar <[email protected]> | 2025-05-21 06:42:51 +0000 |
|---|---|---|
| committer | Ingo Molnar <[email protected]> | 2025-05-21 06:45:03 +0000 |
| commit | 412751aa6991501d7defeadecfede59043d1b5e8 (patch) | |
| tree | ee5026e79128dd4eacb935f76564d7dcc105b24f /drivers/platform/x86/amd/pmf/tee-if.c | |
| parent | x86/xen/msr: Fix uninitialized variable 'err' (diff) | |
| parent | Linux 6.15-rc7 (diff) | |
| download | kernel-412751aa6991501d7defeadecfede59043d1b5e8.tar.gz kernel-412751aa6991501d7defeadecfede59043d1b5e8.zip | |
Merge tag 'v6.15-rc7' into x86/core, to pick up fixes
Pick up build fixes from upstream to make this tree more testable.
Signed-off-by: Ingo Molnar <[email protected]>
Diffstat (limited to 'drivers/platform/x86/amd/pmf/tee-if.c')
| -rw-r--r-- | drivers/platform/x86/amd/pmf/tee-if.c | 23 |
1 files changed, 22 insertions, 1 deletions
diff --git a/drivers/platform/x86/amd/pmf/tee-if.c b/drivers/platform/x86/amd/pmf/tee-if.c index 14b99d8b63d2..d3bd12ad036a 100644 --- a/drivers/platform/x86/amd/pmf/tee-if.c +++ b/drivers/platform/x86/amd/pmf/tee-if.c @@ -334,6 +334,11 @@ static int amd_pmf_start_policy_engine(struct amd_pmf_dev *dev) return 0; } +static inline bool amd_pmf_pb_valid(struct amd_pmf_dev *dev) +{ + return memchr_inv(dev->policy_buf, 0xff, dev->policy_sz); +} + #ifdef CONFIG_AMD_PMF_DEBUG static void amd_pmf_hex_dump_pb(struct amd_pmf_dev *dev) { @@ -361,12 +366,22 @@ static ssize_t amd_pmf_get_pb_data(struct file *filp, const char __user *buf, dev->policy_buf = new_policy_buf; dev->policy_sz = length; + if (!amd_pmf_pb_valid(dev)) { + ret = -EINVAL; + goto cleanup; + } + 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 = { @@ -528,6 +543,12 @@ int amd_pmf_init_smart_pc(struct amd_pmf_dev *dev) memcpy_fromio(dev->policy_buf, dev->policy_base, dev->policy_sz); + if (!amd_pmf_pb_valid(dev)) { + dev_info(dev->dev, "No Smart PC policy present\n"); + ret = -EINVAL; + goto err_free_policy; + } + amd_pmf_hex_dump_pb(dev); dev->prev_data = kzalloc(sizeof(*dev->prev_data), GFP_KERNEL); |
