Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Dan Williams and committed by
Linus Torvalds
4ef197d8 8b3e6cdc

+5 -9
+5 -9
drivers/md/raid5.c
··· 4041 4041 raid5_store_stripe_cache_size(mddev_t *mddev, const char *page, size_t len) 4042 4042 { 4043 4043 raid5_conf_t *conf = mddev_to_conf(mddev); 4044 - char *end; 4045 - int new; 4044 + unsigned long new; 4046 4045 if (len >= PAGE_SIZE) 4047 4046 return -EINVAL; 4048 4047 if (!conf) 4049 4048 return -ENODEV; 4050 4049 4051 - new = simple_strtoul(page, &end, 10); 4052 - if (!*page || (*end && *end != '\n') ) 4050 + if (strict_strtoul(page, 10, &new)) 4053 4051 return -EINVAL; 4054 4052 if (new <= 16 || new > 32768) 4055 4053 return -EINVAL; ··· 4085 4087 raid5_store_preread_threshold(mddev_t *mddev, const char *page, size_t len) 4086 4088 { 4087 4089 raid5_conf_t *conf = mddev_to_conf(mddev); 4088 - char *end; 4089 - int new; 4090 + unsigned long new; 4090 4091 if (len >= PAGE_SIZE) 4091 4092 return -EINVAL; 4092 4093 if (!conf) 4093 4094 return -ENODEV; 4094 4095 4095 - new = simple_strtoul(page, &end, 10); 4096 - if (!*page || (*end && *end != '\n')) 4096 + if (strict_strtoul(page, 10, &new)) 4097 4097 return -EINVAL; 4098 - if (new > conf->max_nr_stripes || new < 0) 4098 + if (new > conf->max_nr_stripes) 4099 4099 return -EINVAL; 4100 4100 conf->bypass_threshold = new; 4101 4101 return len;