diff options
author | Dan Carpenter <dan.carpenter@oracle.com> | 2015-09-28 12:56:36 +0300 |
---|---|---|
committer | Lee Jones <lee.jones@linaro.org> | 2015-10-30 17:19:47 +0000 |
commit | f3a654c5198b1de3e6241ab6a9d5c52295504970 (patch) | |
tree | 5a939b645442150e64df5576fe889bac1697c6d1 /drivers/mfd | |
parent | ad698ea425f90e4d09694c2cf7155cad4d7badb3 (diff) | |
download | linux-f3a654c5198b1de3e6241ab6a9d5c52295504970.tar.bz2 |
mfd: intel_soc_pmic_bxtwc: 64 bit bug in bxtwc_val_store()
The call to kstrtoul() will corrupt memory on 64 bit systems because an
int is 4 bytes and a long is 8.
Also it's not a good idea to let users trigger a dev_err() because it
just ends up flooding /var/log/messages so I removed the printk.
Fixes: 2ddd2086ea9c ('mfd: add Intel Broxton Whiskey Cove PMIC driver')
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Lee Jones <lee.jones@linaro.org>
Diffstat (limited to 'drivers/mfd')
-rw-r--r-- | drivers/mfd/intel_soc_pmic_bxtwc.c | 7 |
1 files changed, 3 insertions, 4 deletions
diff --git a/drivers/mfd/intel_soc_pmic_bxtwc.c b/drivers/mfd/intel_soc_pmic_bxtwc.c index 40acaff2e1c3..b9428767e615 100644 --- a/drivers/mfd/intel_soc_pmic_bxtwc.c +++ b/drivers/mfd/intel_soc_pmic_bxtwc.c @@ -297,10 +297,9 @@ static ssize_t bxtwc_val_store(struct device *dev, unsigned int val; struct intel_soc_pmic *pmic = dev_get_drvdata(dev); - if (kstrtoul(buf, 0, (unsigned long *)&val)) { - dev_err(dev, "Invalid register value\n"); - return -EINVAL; - } + ret = kstrtouint(buf, 0, &val); + if (ret) + return ret; ret = regmap_write(pmic->regmap, bxtwc_reg_addr, val); if (ret) { |