From: Dan Carpenter <dan.carpenter@oracle.com>
To: kernel-janitors@vger.kernel.org
Subject: [patch] mfd: 64 bit bug in bxtwc_val_store()
Date: Mon, 28 Sep 2015 09:56:36 +0000 [thread overview]
Message-ID: <20150928095636.GB11367@mwanda> (raw)
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>
diff --git a/drivers/mfd/intel_soc_pmic_bxtwc.c b/drivers/mfd/intel_soc_pmic_bxtwc.c
index 40acaff..b942876 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) {
next reply other threads:[~2015-09-28 9:56 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-09-28 9:56 Dan Carpenter [this message]
2015-10-01 11:51 ` [patch] mfd: 64 bit bug in bxtwc_val_store() Lee Jones
2015-10-01 15:13 ` Dan Carpenter
2015-10-01 15:16 ` Dan Carpenter
2015-10-01 15:23 ` Lee Jones
2015-10-01 15:35 ` Dan Carpenter
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20150928095636.GB11367@mwanda \
--to=dan.carpenter@oracle.com \
--cc=kernel-janitors@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox