projects
/
firefly-linux-kernel-4.4.55.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/jikos/hid
[firefly-linux-kernel-4.4.55.git]
/
samples
/
kobject
/
kobject-example.c
diff --git
a/samples/kobject/kobject-example.c
b/samples/kobject/kobject-example.c
index 01562e0d499202a0005c61443f36bdf11a33160c..2e0740f06cd70d7e5837975ced3e2608a203afc1 100644
(file)
--- 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,
static ssize_t foo_store(struct kobject *kobj, struct kobj_attribute *attr,
const char *buf, size_t count)
{
static ssize_t foo_store(struct kobject *kobj, struct kobj_attribute *attr,
const char *buf, size_t count)
{
- sscanf(buf, "%du", &foo);
+ int ret;
+
+ ret = kstrtoint(buf, 10, &foo);
+ if (ret < 0)
+ return ret;
+
return count;
}
return count;
}
@@
-63,9
+68,12
@@
static ssize_t b_show(struct kobject *kobj, struct kobj_attribute *attr,
static ssize_t b_store(struct kobject *kobj, struct kobj_attribute *attr,
const char *buf, size_t count)
{
static ssize_t b_store(struct kobject *kobj, struct kobj_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)
baz = var;
else
if (strcmp(attr->attr.name, "baz") == 0)
baz = var;
else
@@
-134,5
+142,5
@@
static void __exit example_exit(void)
module_init(example_init);
module_exit(example_exit);
module_init(example_init);
module_exit(example_exit);
-MODULE_LICENSE("GPL");
+MODULE_LICENSE("GPL
v2
");
MODULE_AUTHOR("Greg Kroah-Hartman <greg@kroah.com>");
MODULE_AUTHOR("Greg Kroah-Hartman <greg@kroah.com>");