Commit 2b0122aa authored by David Disseldorp's avatar David Disseldorp Committed by David Sterba
Browse files

btrfs: sysfs: validate scrub_speed_max value



The value set as scrub_speed_max accepts size with suffixes
(k/m/g/t/p/e) but we should still validate it for trailing characters,
similar to what we do with chunk_size_store.

CC: stable@vger.kernel.org # 5.15+
Signed-off-by: default avatarDavid Disseldorp <ddiss@suse.de>
Reviewed-by: default avatarDavid Sterba <dsterba@suse.com>
Signed-off-by: default avatarDavid Sterba <dsterba@suse.com>
parent 6140ba8a
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -1783,6 +1783,10 @@ static ssize_t btrfs_devinfo_scrub_speed_max_store(struct kobject *kobj,
	unsigned long long limit;

	limit = memparse(buf, &endptr);
	/* There could be trailing '\n', also catch any typos after the value. */
	endptr = skip_spaces(endptr);
	if (*endptr != 0)
		return -EINVAL;
	WRITE_ONCE(device->scrub_speed_max, limit);
	return len;
}