diff options
Diffstat (limited to 'drivers/base/core.c')
-rw-r--r-- | drivers/base/core.c | 21 |
1 files changed, 14 insertions, 7 deletions
diff --git a/drivers/base/core.c b/drivers/base/core.c index 04bbcd779e11..ed145fbfeddf 100644 --- a/drivers/base/core.c +++ b/drivers/base/core.c | |||
@@ -794,10 +794,12 @@ ssize_t device_store_ulong(struct device *dev, | |||
794 | const char *buf, size_t size) | 794 | const char *buf, size_t size) |
795 | { | 795 | { |
796 | struct dev_ext_attribute *ea = to_ext_attr(attr); | 796 | struct dev_ext_attribute *ea = to_ext_attr(attr); |
797 | char *end; | 797 | int ret; |
798 | unsigned long new = simple_strtoul(buf, &end, 0); | 798 | unsigned long new; |
799 | if (end == buf) | 799 | |
800 | return -EINVAL; | 800 | ret = kstrtoul(buf, 0, &new); |
801 | if (ret) | ||
802 | return ret; | ||
801 | *(unsigned long *)(ea->var) = new; | 803 | *(unsigned long *)(ea->var) = new; |
802 | /* Always return full write size even if we didn't consume all */ | 804 | /* Always return full write size even if we didn't consume all */ |
803 | return size; | 805 | return size; |
@@ -818,9 +820,14 @@ ssize_t device_store_int(struct device *dev, | |||
818 | const char *buf, size_t size) | 820 | const char *buf, size_t size) |
819 | { | 821 | { |
820 | struct dev_ext_attribute *ea = to_ext_attr(attr); | 822 | struct dev_ext_attribute *ea = to_ext_attr(attr); |
821 | char *end; | 823 | int ret; |
822 | long new = simple_strtol(buf, &end, 0); | 824 | long new; |
823 | if (end == buf || new > INT_MAX || new < INT_MIN) | 825 | |
826 | ret = kstrtol(buf, 0, &new); | ||
827 | if (ret) | ||
828 | return ret; | ||
829 | |||
830 | if (new > INT_MAX || new < INT_MIN) | ||
824 | return -EINVAL; | 831 | return -EINVAL; |
825 | *(int *)(ea->var) = new; | 832 | *(int *)(ea->var) = new; |
826 | /* Always return full write size even if we didn't consume all */ | 833 | /* Always return full write size even if we didn't consume all */ |