Commit f3a654c5 authored by Dan Carpenter's avatar Dan Carpenter Committed by Lee Jones

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: default avatarDan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: default avatarLee Jones <lee.jones@linaro.org>
parent ad698ea4
...@@ -297,10 +297,9 @@ static ssize_t bxtwc_val_store(struct device *dev, ...@@ -297,10 +297,9 @@ static ssize_t bxtwc_val_store(struct device *dev,
unsigned int val; unsigned int val;
struct intel_soc_pmic *pmic = dev_get_drvdata(dev); struct intel_soc_pmic *pmic = dev_get_drvdata(dev);
if (kstrtoul(buf, 0, (unsigned long *)&val)) { ret = kstrtouint(buf, 0, &val);
dev_err(dev, "Invalid register value\n"); if (ret)
return -EINVAL; return ret;
}
ret = regmap_write(pmic->regmap, bxtwc_reg_addr, val); ret = regmap_write(pmic->regmap, bxtwc_reg_addr, val);
if (ret) { if (ret) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment