Re: [PATCH] orangefs-debugfs: fix a missing-check bug in debug_string_to_mask()

From: Jiri Slaby
Date: Wed Jun 05 2019 - 02:36:47 EST


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