Skip to content

Commit

Permalink
platform/x86: intel_pmc_core: Respect error code of kstrtou32_from_us…
Browse files Browse the repository at this point in the history
…er()

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>
  • Loading branch information
Andy Shevchenko committed Jan 10, 2020
1 parent e883caf commit 9592438
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions drivers/platform/x86/intel_pmc_core.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 9592438

Please sign in to comment.