summaryrefslogtreecommitdiffstats
path: root/kernel
diff options
context:
space:
mode:
authorShaohua Li <shli@fb.com>2017-05-19 08:04:59 -0700
committerJens Axboe <axboe@fb.com>2017-05-19 09:21:15 -0600
commit5f3394530fbe90d3bcd1c204618960bc50236578 (patch)
treefb7425b6f00ef9186ab270bb13149c2d8881434f /kernel
parent69c8ebf83213e6165b13d94ec599b861467ee2dc (diff)
downloadlinux-stable-5f3394530fbe90d3bcd1c204618960bc50236578.tar.gz
linux-stable-5f3394530fbe90d3bcd1c204618960bc50236578.tar.bz2
linux-stable-5f3394530fbe90d3bcd1c204618960bc50236578.zip
blktrace: fix integer parse
sscanf is a very poor way to parse integer. For example, I input "discard" for act_mask, it gets 0xd and completely messes up. Using correct API to do integer parse. This patch also makes attributes accept any base of integer. Signed-off-by: Shaohua Li <shli@fb.com> Signed-off-by: Jens Axboe <axboe@fb.com>
Diffstat (limited to 'kernel')
-rw-r--r--kernel/trace/blktrace.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/kernel/trace/blktrace.c b/kernel/trace/blktrace.c
index bd8ae8d5ae9c..193c5f5e3f79 100644
--- a/kernel/trace/blktrace.c
+++ b/kernel/trace/blktrace.c
@@ -1662,14 +1662,14 @@ static ssize_t sysfs_blk_trace_attr_store(struct device *dev,
goto out;
if (attr == &dev_attr_act_mask) {
- if (sscanf(buf, "%llx", &value) != 1) {
+ if (kstrtoull(buf, 0, &value)) {
/* Assume it is a list of trace category names */
ret = blk_trace_str2mask(buf);
if (ret < 0)
goto out;
value = ret;
}
- } else if (sscanf(buf, "%llu", &value) != 1)
+ } else if (kstrtoull(buf, 0, &value))
goto out;
ret = -ENXIO;