All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] wimax: debug: fix a missing-check bug in d_parse_params()
@ 2019-05-30  9:39 Gen Zhang
  2019-06-05  6:33 ` Jiri Slaby
  0 siblings, 1 reply; 3+ messages in thread
From: Gen Zhang @ 2019-05-30  9:39 UTC (permalink / raw)
  To: inaky.perez-gonzalez; +Cc: linux-wimax, linux-kernel

In d_parse_params(), 'params_orig' is allocated by kstrdup(). It returns
NULL when fails. So 'params_orig' should be checked.

Signed-off-by: Gen Zhang <blackgod016574@gmail.com>
---
diff --git a/include/linux/wimax/debug.h b/include/linux/wimax/debug.h
index aaf24ba..bacd6cb 100644
--- a/include/linux/wimax/debug.h
+++ b/include/linux/wimax/debug.h
@@ -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(&params, " ");

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] wimax: debug: fix a missing-check bug in d_parse_params()
  2019-05-30  9:39 [PATCH] wimax: debug: fix a missing-check bug in d_parse_params() Gen Zhang
@ 2019-06-05  6:33 ` Jiri Slaby
  2019-06-05 16:11   ` Gen Zhang
  0 siblings, 1 reply; 3+ messages in thread
From: Jiri Slaby @ 2019-06-05  6:33 UTC (permalink / raw)
  To: Gen Zhang, inaky.perez-gonzalez; +Cc: linux-wimax, linux-kernel

On 30. 05. 19, 11:39, Gen Zhang wrote:
> In d_parse_params(), 'params_orig' is allocated by kstrdup(). It returns
> NULL when fails. So 'params_orig' should be checked.
> 
> Signed-off-by: Gen Zhang <blackgod016574@gmail.com>
> ---
> diff --git a/include/linux/wimax/debug.h b/include/linux/wimax/debug.h
> index aaf24ba..bacd6cb 100644
> --- a/include/linux/wimax/debug.h
> +++ b/include/linux/wimax/debug.h
> @@ -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,
-- 
js
suse labs

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] wimax: debug: fix a missing-check bug in d_parse_params()
  2019-06-05  6:33 ` Jiri Slaby
@ 2019-06-05 16:11   ` Gen Zhang
  0 siblings, 0 replies; 3+ messages in thread
From: Gen Zhang @ 2019-06-05 16:11 UTC (permalink / raw)
  To: Jiri Slaby; +Cc: inaky.perez-gonzalez, linux-wimax, linux-kernel

On Wed, Jun 05, 2019 at 08:33:31AM +0200, Jiri Slaby wrote:
> On 30. 05. 19, 11:39, Gen Zhang wrote:
> > In d_parse_params(), 'params_orig' is allocated by kstrdup(). It returns
> > NULL when fails. So 'params_orig' should be checked.
> > 
> > Signed-off-by: Gen Zhang <blackgod016574@gmail.com>
> > ---
> > diff --git a/include/linux/wimax/debug.h b/include/linux/wimax/debug.h
> > index aaf24ba..bacd6cb 100644
> > --- a/include/linux/wimax/debug.h
> > +++ b/include/linux/wimax/debug.h
> > @@ -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 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
> 
> thanks,
> -- 
> js
> suse labs

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2019-06-05 16:11 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-05-30  9:39 [PATCH] wimax: debug: fix a missing-check bug in d_parse_params() Gen Zhang
2019-06-05  6:33 ` Jiri Slaby
2019-06-05 16:11   ` Gen Zhang

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.