提交 5cc6b16e 编写于 作者: B Borislav Petkov

RAS/CEC: Do not set decay value on error

When the value requested doesn't match the allowed (min,max) range,
the @data buffer should not be modified with the invalid value because
reading "decay_interval" shows it otherwise as if the previous write
succeeded.

Move the data write after the check.
Signed-off-by: NBorislav Petkov <bp@suse.de>
Cc: Tony Luck <tony.luck@intel.com>
Cc: linux-edac <linux-edac@vger.kernel.org>
上级 de0e0624
...@@ -371,17 +371,17 @@ DEFINE_DEBUGFS_ATTRIBUTE(pfn_ops, u64_get, pfn_set, "0x%llx\n"); ...@@ -371,17 +371,17 @@ DEFINE_DEBUGFS_ATTRIBUTE(pfn_ops, u64_get, pfn_set, "0x%llx\n");
static int decay_interval_set(void *data, u64 val) static int decay_interval_set(void *data, u64 val)
{ {
*(u64 *)data = val;
if (val < CEC_DECAY_MIN_INTERVAL) if (val < CEC_DECAY_MIN_INTERVAL)
return -EINVAL; return -EINVAL;
if (val > CEC_DECAY_MAX_INTERVAL) if (val > CEC_DECAY_MAX_INTERVAL)
return -EINVAL; return -EINVAL;
*(u64 *)data = val;
decay_interval = val; decay_interval = val;
cec_mod_work(decay_interval); cec_mod_work(decay_interval);
return 0; return 0;
} }
DEFINE_DEBUGFS_ATTRIBUTE(decay_interval_ops, u64_get, decay_interval_set, "%lld\n"); DEFINE_DEBUGFS_ATTRIBUTE(decay_interval_ops, u64_get, decay_interval_set, "%lld\n");
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册