wimax: debug: fix a missing-check bug in d_parse_params()
PATCH 1/1 wimax: debug: fix a missing-check bug in d_parse_params()
In d_parse_params(), 'params_orig' is allocated by kstrdup(). It returns NULL when fails. So 'params_orig' should be checked.
---
include/linux/wimax/debug.h +5 -0
@@ -496,6 +496,11 @@ void d_parse_params(struct d_level *d_level, size_t d_level_size,if (_params ==NULL )return ; params_orig =kstrdup (_params,GFP_KERNEL ); +if (!params_orig) { +printk (KERN_ERR "%s: can't duplicate string '%s'\n" , + tag, _params); +return ; + } params = params_orig;while (1 ) { token =strsep (¶ms," " );
Quoted 10 lines · Gen Zhang
In
d_parse_params(), 'params_orig' is allocated bykstrdup(). It returns NULL when fails. So 'params_orig' should be checked.Signed-off-by Gen Zhang <[email protected]>---
include/linux/wimax/debug.h +0
-0
include/linux/wimax/debug.h void d_parse_params(struct d_level *d_level, size_t d_level_size, · line 501
Quoted 6 lines
include/linux/wimax/debug.h +3
-0@@ -496,6 +496,11 @@ void d_parse_params(struct d_level *d_level, size_t d_level_size,if (_params ==NULL )return ; params_orig =kstrdup (_params,GFP_KERNEL ); +if (!params_orig) { +printk (KERN_ERR "%s: can't duplicate string '%s'\n" , + tag, _params);
We use pr_err these days.
thanks,
Signature · 2 lines
js suse labs
Quoted 4 lines · Jiri Slaby
Quoted 3 lines · Gen Zhang
In
d_parse_params(), 'params_orig' is allocated bykstrdup(). It returns NULL when fails. So 'params_orig' should be checked.
Quoted 15 lines
include/linux/wimax/debug.h void d_parse_params(struct d_level *d_level, size_t d_level_size, · line 501
Quoted 13 lines
Signed-off-by Gen Zhang <[email protected]>---
include/linux/wimax/debug.h +3
-0@@ -496,6 +496,11 @@ void d_parse_params(struct d_level *d_level, size_t d_level_size,if (_params ==NULL )return ; params_orig =kstrdup (_params,GFP_KERNEL ); +if (!params_orig) { +printk (KERN_ERR "%s: can't duplicate string '%s'\n" , + tag, _params);We use
pr_errthese days.
Thanks for your reply. I used printk() because at least in this file, printk() is used.
Should I change printk() to pr_err() and revise this patch, or should all printk() in this file be changed? I hope you can give me some specific instructions. Actually I don't know what to do when getting this reply...
Thanks
Gen
Quoted 5 lines
thanks,
Signature · 2 lines
js suse labs