md: raid5.c convert simple_strtoul to strict_strtoul
strict_strtoul handles the open-coded sanity checks in raid5_store_stripe_cache_size and raid5_store_preread_threshold Acked-by: NeilBrown <neilb@suse.de> Signed-off-by: Dan Williams <dan.j.williams@intel.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
This commit is contained in:
parent
8b3e6cdc53
commit
4ef197d87a
@ -4041,15 +4041,13 @@ static ssize_t
|
|||||||
raid5_store_stripe_cache_size(mddev_t *mddev, const char *page, size_t len)
|
raid5_store_stripe_cache_size(mddev_t *mddev, const char *page, size_t len)
|
||||||
{
|
{
|
||||||
raid5_conf_t *conf = mddev_to_conf(mddev);
|
raid5_conf_t *conf = mddev_to_conf(mddev);
|
||||||
char *end;
|
unsigned long new;
|
||||||
int new;
|
|
||||||
if (len >= PAGE_SIZE)
|
if (len >= PAGE_SIZE)
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
if (!conf)
|
if (!conf)
|
||||||
return -ENODEV;
|
return -ENODEV;
|
||||||
|
|
||||||
new = simple_strtoul(page, &end, 10);
|
if (strict_strtoul(page, 10, &new))
|
||||||
if (!*page || (*end && *end != '\n') )
|
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
if (new <= 16 || new > 32768)
|
if (new <= 16 || new > 32768)
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
@ -4087,17 +4085,15 @@ static ssize_t
|
|||||||
raid5_store_preread_threshold(mddev_t *mddev, const char *page, size_t len)
|
raid5_store_preread_threshold(mddev_t *mddev, const char *page, size_t len)
|
||||||
{
|
{
|
||||||
raid5_conf_t *conf = mddev_to_conf(mddev);
|
raid5_conf_t *conf = mddev_to_conf(mddev);
|
||||||
char *end;
|
unsigned long new;
|
||||||
int new;
|
|
||||||
if (len >= PAGE_SIZE)
|
if (len >= PAGE_SIZE)
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
if (!conf)
|
if (!conf)
|
||||||
return -ENODEV;
|
return -ENODEV;
|
||||||
|
|
||||||
new = simple_strtoul(page, &end, 10);
|
if (strict_strtoul(page, 10, &new))
|
||||||
if (!*page || (*end && *end != '\n'))
|
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
if (new > conf->max_nr_stripes || new < 0)
|
if (new > conf->max_nr_stripes)
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
conf->bypass_threshold = new;
|
conf->bypass_threshold = new;
|
||||||
return len;
|
return len;
|
||||||
|
Loading…
Reference in New Issue
Block a user