diff options
Diffstat (limited to 'samples/kobject/kset-example.c')
-rw-r--r-- | samples/kobject/kset-example.c | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/samples/kobject/kset-example.c b/samples/kobject/kset-example.c index ab5e447ec238..a55bff52bde3 100644 --- a/samples/kobject/kset-example.c +++ b/samples/kobject/kset-example.c @@ -120,7 +120,12 @@ static ssize_t foo_show(struct foo_obj *foo_obj, struct foo_attribute *attr, static ssize_t foo_store(struct foo_obj *foo_obj, struct foo_attribute *attr, const char *buf, size_t count) { - sscanf(buf, "%du", &foo_obj->foo); + int ret; + + ret = kstrtoint(buf, 10, &foo_obj->foo); + if (ret < 0) + return ret; + return count; } @@ -147,9 +152,12 @@ static ssize_t b_show(struct foo_obj *foo_obj, struct foo_attribute *attr, static ssize_t b_store(struct foo_obj *foo_obj, struct foo_attribute *attr, const char *buf, size_t count) { - int var; + int var, ret; + + ret = kstrtoint(buf, 10, &var); + if (ret < 0) + return ret; - sscanf(buf, "%du", &var); if (strcmp(attr->attr.name, "baz") == 0) foo_obj->baz = var; else @@ -277,5 +285,5 @@ static void __exit example_exit(void) module_init(example_init); module_exit(example_exit); -MODULE_LICENSE("GPL"); +MODULE_LICENSE("GPL v2"); MODULE_AUTHOR("Greg Kroah-Hartman <greg@kroah.com>"); |