aboutsummaryrefslogtreecommitdiffstats
path: root/samples/kobject/kobject-example.c
diff options
context:
space:
mode:
Diffstat (limited to 'samples/kobject/kobject-example.c')
-rw-r--r--samples/kobject/kobject-example.c14
1 files changed, 11 insertions, 3 deletions
diff --git a/samples/kobject/kobject-example.c b/samples/kobject/kobject-example.c
index 01562e0d4992..063aaece0bcd 100644
--- a/samples/kobject/kobject-example.c
+++ b/samples/kobject/kobject-example.c
@@ -36,7 +36,12 @@ static ssize_t foo_show(struct kobject *kobj, struct kobj_attribute *attr,
36static ssize_t foo_store(struct kobject *kobj, struct kobj_attribute *attr, 36static ssize_t foo_store(struct kobject *kobj, struct kobj_attribute *attr,
37 const char *buf, size_t count) 37 const char *buf, size_t count)
38{ 38{
39 sscanf(buf, "%du", &foo); 39 int ret;
40
41 ret = kstrtoint(buf, 10, &foo);
42 if (ret < 0)
43 return ret;
44
40 return count; 45 return count;
41} 46}
42 47
@@ -63,9 +68,12 @@ static ssize_t b_show(struct kobject *kobj, struct kobj_attribute *attr,
63static ssize_t b_store(struct kobject *kobj, struct kobj_attribute *attr, 68static ssize_t b_store(struct kobject *kobj, struct kobj_attribute *attr,
64 const char *buf, size_t count) 69 const char *buf, size_t count)
65{ 70{
66 int var; 71 int var, ret;
72
73 ret = kstrtoint(buf, 10, &var);
74 if (ret < 0)
75 return ret;
67 76
68 sscanf(buf, "%du", &var);
69 if (strcmp(attr->attr.name, "baz") == 0) 77 if (strcmp(attr->attr.name, "baz") == 0)
70 baz = var; 78 baz = var;
71 else 79 else