The Linux Kernel Mailing List
 help / color / mirror / Atom feed
* [PATCH] orangefs-debugfs: fix a missing-check bug in debug_string_to_mask()
@ 2019-05-30  9:04 Gen Zhang
  2019-06-05  6:32 ` Jiri Slaby
  0 siblings, 1 reply; 2+ messages in thread
From: Gen Zhang @ 2019-05-30  9:04 UTC (permalink / raw)
  To: hubcap, martin; +Cc: devel, linux-kernel

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

Signed-off-by: Gen Zhang <blackgod016574.gmail>
---
diff --git a/fs/orangefs/orangefs-debugfs.c b/fs/orangefs/orangefs-debugfs.c
index 87b1a6f..a9a9aac 100644
--- a/fs/orangefs/orangefs-debugfs.c
+++ b/fs/orangefs/orangefs-debugfs.c
@@ -888,6 +888,8 @@ static void debug_string_to_mask(char *debug_string, void *mask, int type)
 	char *unchecked_keyword;
 	int i;
 	char *strsep_fodder = kstrdup(debug_string, GFP_KERNEL);
+	if (!strsep_fodder)
+		return;
 	char *original_pointer;
 	int element_count = 0;
 	struct client_debug_mask *c_mask = NULL;

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

* Re: [PATCH] orangefs-debugfs: fix a missing-check bug in debug_string_to_mask()
  2019-05-30  9:04 [PATCH] orangefs-debugfs: fix a missing-check bug in debug_string_to_mask() Gen Zhang
@ 2019-06-05  6:32 ` Jiri Slaby
  0 siblings, 0 replies; 2+ messages in thread
From: Jiri Slaby @ 2019-06-05  6:32 UTC (permalink / raw)
  To: Gen Zhang, hubcap, martin; +Cc: devel, linux-kernel

On 30. 05. 19, 11:04, Gen Zhang wrote:
> In debug_string_to_mask(), 'strsep_fodder' is allocated by kstrdup().
> It returns NULL when fails. So 'strsep_fodder' should be checked.
> 
> Signed-off-by: Gen Zhang <blackgod016574.gmail>
> ---
> diff --git a/fs/orangefs/orangefs-debugfs.c b/fs/orangefs/orangefs-debugfs.c
> index 87b1a6f..a9a9aac 100644
> --- a/fs/orangefs/orangefs-debugfs.c
> +++ b/fs/orangefs/orangefs-debugfs.c
> @@ -888,6 +888,8 @@ static void debug_string_to_mask(char *debug_string, void *mask, int type)
>  	char *unchecked_keyword;
>  	int i;
>  	char *strsep_fodder = kstrdup(debug_string, GFP_KERNEL);
> +	if (!strsep_fodder)
> +		return;
>  	char *original_pointer;

You should get a compiler error/warning about mixing declarations with code.

thanks,
-- 
js
suse labs

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

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

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-05-30  9:04 [PATCH] orangefs-debugfs: fix a missing-check bug in debug_string_to_mask() Gen Zhang
2019-06-05  6:32 ` Jiri Slaby

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox