lib/kobject: simplify the kobject_init function
Subsystems (2)
PATCH 1/3 lib/kobject: simplify the kobject_init function
From: Dong Hao <[email protected]>
The printk() function at the end of function kobject_init() already had '\n', so remove the duplicated one.
--- lib/kobject.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
lib/kobject.c +1 -1
@@ -274,7 +274,7 @@ void kobject_init(struct kobject *kobj, struct kobj_type *ktype) goto error; }if (!ktype) { - err_str ="must have a ktype to be initialized properly!\n" ; + err_str ="must have a ktype to be initialized properly!" ; goto error; }if (kobj->state_initialized) {
Signature · 1 line
1.7.9.5
PATCH 2/3 lib/kobject: Panic when kobj or ktype is not properly assigned
From: Dong Hao <[email protected]>
kobj and ktype are two important attributes which will be used after kobject_init(), and (!kobj)|(!ktype) may cause FS corruption which could not be recovered. Panic instead of dump_stack() when neither kobj nor ktype is properly assigned to detect the bug early.
--- lib/kobject.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
lib/kobject.c +1 -1
@@ -290,7 +290,7 @@ void kobject_init(struct kobject *kobj, struct kobj_type *ktype) error:printk (KERN_ERR "kobject (%p): %s\n" , kobj, err_str); -dump_stack (); +BUG_ON (1 ); }EXPORT_SYMBOL (kobject_init);
Signature · 1 line
1.7.9.5
Re: [PATCH 2/3] lib/kobject: Panic when kobj or ktype is not properly assigned
Quoted 5 lines · Dong Hao
From: Dong Hao <[email protected]>
kobj and ktype are two important attributes which will be used after
kobject_init(),and (!kobj)|(!ktype) may cause FS corruption which could not be recovered.
delete this line, i am not very convinced about corruption ...
Quoted 21 lines
Panic instead of
dump_stack()when neither kobj nor ktype is properly assigned to detect the bug early.Signed-off-by Dong Hao <[email protected]>--- lib/kobject.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)lib/kobject.c +1
-1@@ -290,7 +290,7 @@ void kobject_init(struct kobject *kobj, struct kobj_type *ktype) error:printk (KERN_ERR "kobject (%p): %s\n" , kobj, err_str); -dump_stack (); +BUG_ON (1 ); }EXPORT_SYMBOL (kobject_init);
Greg KH
maintainerRe: [PATCH 2/3] lib/kobject: Panic when kobj or ktype is not properly assigned
In reply to Dong HaoQuoted 17 lines · Dong Hao
From: Dong Hao <[email protected]>
kobj and ktype are two important attributes which will be used after
kobject_init(), and (!kobj)|(!ktype) may cause FS corruption which could not be recovered. Panic instead ofdump_stack()when neither kobj nor ktype is properly assigned to detect the bug early.Signed-off-by Dong Hao <[email protected]>--- lib/kobject.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)lib/kobject.c +0
-0
lib/kobject.c void kobject_init(struct kobject *kobj, struct kobj_type *ktype) · line 293
Quoted 5 lines
lib/kobject.c +1
-1@@ -290,7 +290,7 @@ void kobject_init(struct kobject *kobj, struct kobj_type *ktype) error:printk (KERN_ERR "kobject (%p): %s\n" , kobj, err_str); -dump_stack (); +BUG_ON (1 );
You just crashed the machine. That's horrible, and unacceptable.
*plonk*
PATCH 3/3 lib/kobject: WARN_ON corresponds to BUG_ON
In reply to Dong HaoFrom: Dong Hao <[email protected]>
WARN_ON corresponds to BUG_ON and also gets more info.
--- lib/kobject.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
lib/kobject.c +1 -1
@@ -281,7 +281,7 @@ void kobject_init(struct kobject *kobj, struct kobj_type *ktype)/* do not error out as sometimes we can recover */ printk (KERN_ERR "kobject (%p): tried to init an initialized " "object, something is seriously wrong.\n" , kobj); -dump_stack (); +WARN_ON (1 ); }kobject_init_internal (kobj);
Signature · 1 line
1.7.9.5
Re: [PATCH 3/3] lib/kobject: WARN_ON corresponds to BUG_ON
Quoted 3 lines · Dong Hao
From: Dong Hao <[email protected]>
WARN_ONcorresponds toBUG_ONand also gets more info.
Change the log like this:
like the comments said, double initialize a kobj is wrong but can be recoverd, using WARN_ON to warn the developer also it can get more info.
(Or you refine the code by yourself.)
Quoted 20 lines
Signed-off-by Dong Hao <[email protected]>--- lib/kobject.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)lib/kobject.c +1
-1@@ -281,7 +281,7 @@ void kobject_init(struct kobject *kobj, struct kobj_type *ktype)/* do not error out as sometimes we can recover */ printk (KERN_ERR "kobject (%p): tried to init an initialized " "object, something is seriously wrong.\n" , kobj); -dump_stack (); +WARN_ON (1 ); }kobject_init_internal (kobj);
Re: [PATCH 3/3] lib/kobject: WARN_ON corresponds to BUG_ON
Quoted 11 lines · Xiao Guangrong
Quoted 3 lines · Dong Hao
From: Dong Hao <[email protected]>
WARN_ONcorresponds toBUG_ONand also gets more info.Change the log like this:
like the comments said, double initialize a kobj is wrong but can be recoverd, usingWARN_ONto warn the developer also it can get more info.(Or you refine the code by yourself.)
s/code/comment
Quoted 22 lines
Quoted 21 lines
Signed-off-by Dong Hao <[email protected]>--- lib/kobject.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)lib/kobject.c +1
-1@@ -281,7 +281,7 @@ void kobject_init(struct kobject *kobj, struct kobj_type *ktype)/* do not error out as sometimes we can recover */ printk (KERN_ERR "kobject (%p): tried to init an initialized " "object, something is seriously wrong.\n" , kobj); -dump_stack (); +WARN_ON (1 ); }kobject_init_internal (kobj);
Greg KH
maintainerRe: [PATCH 3/3] lib/kobject: WARN_ON corresponds to BUG_ON
In reply to Dong HaoQuoted 3 lines · Dong Hao
From: Dong Hao <[email protected]>
WARN_ONcorresponds toBUG_ONand also gets more info.
Huh? No.
Please stop, don't resend these.
greg k-h
Greg KH
maintainerQuoted 4 lines · Dong Hao
From: Dong Hao <[email protected]>
The
printk()function at the end of functionkobject_init()already had '\n', so remove the duplicated one.
Your subject doesn't match this description.