Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 5f339453 authored by Shaohua Li's avatar Shaohua Li Committed by Jens Axboe
Browse files

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: default avatarShaohua Li <shli@fb.com>
Signed-off-by: default avatarJens Axboe <axboe@fb.com>
parent 69c8ebf8
Loading
Loading
Loading
Loading
+2 −2
Original line number Original line Diff line number Diff line
@@ -1662,14 +1662,14 @@ static ssize_t sysfs_blk_trace_attr_store(struct device *dev,
		goto out;
		goto out;


	if (attr == &dev_attr_act_mask) {
	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 */
			/* Assume it is a list of trace category names */
			ret = blk_trace_str2mask(buf);
			ret = blk_trace_str2mask(buf);
			if (ret < 0)
			if (ret < 0)
				goto out;
				goto out;
			value = ret;
			value = ret;
		}
		}
	} else if (sscanf(buf, "%llu", &value) != 1)
	} else if (kstrtoull(buf, 0, &value))
		goto out;
		goto out;


	ret = -ENXIO;
	ret = -ENXIO;