diff options
author | Andy Shevchenko | 2019-12-18 20:42:29 +0200 |
---|---|---|
committer | Andy Shevchenko | 2020-01-10 11:50:32 +0200 |
commit | 9592438886756ce7d1327e9ec998b8bc0c1541bc (patch) | |
tree | 772e5dce06e1510c98844ab324a59b506a1dd92a /drivers/platform | |
parent | e883cafd8de012edc979935610b04204c4c2a742 (diff) |
platform/x86: intel_pmc_core: Respect error code of kstrtou32_from_user()
kstrtou32_from_user() may return different error codes on certain
circumstances. Respect all possible values.
While here, move it out of the lock: there is no data access that lock guards.
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Diffstat (limited to 'drivers/platform')
-rw-r--r-- | drivers/platform/x86/intel_pmc_core.c | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/drivers/platform/x86/intel_pmc_core.c b/drivers/platform/x86/intel_pmc_core.c index 92d4b4763f18..4a20540425c4 100644 --- a/drivers/platform/x86/intel_pmc_core.c +++ b/drivers/platform/x86/intel_pmc_core.c @@ -629,15 +629,15 @@ static ssize_t pmc_core_ltr_ignore_write(struct file *file, const char __user struct pmc_dev *pmcdev = &pmc; const struct pmc_reg_map *map = pmcdev->map; u32 val, buf_size, fd; - int err = 0; + int err; buf_size = count < 64 ? count : 64; - mutex_lock(&pmcdev->lock); - if (kstrtou32_from_user(userbuf, buf_size, 10, &val)) { - err = -EFAULT; - goto out_unlock; - } + err = kstrtou32_from_user(userbuf, buf_size, 10, &val); + if (err) + return err; + + mutex_lock(&pmcdev->lock); if (val > map->ltr_ignore_max) { err = -EINVAL; |