lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <4936c8d8-9b69-1385-1bbf-9d19ac08d061@akamai.com>
Date:   Thu, 13 Jun 2019 10:33:23 -0400
From:   Jason Baron <jbaron@...mai.com>
To:     Greg Kroah-Hartman <gregkh@...uxfoundation.org>
Cc:     linux-kernel@...r.kernel.org
Subject: Re: [PATCH] lib: dynamic_debug: no need to check return value of
 debugfs_create functions

On 6/12/19 11:35 AM, Greg Kroah-Hartman wrote:
> When calling debugfs functions, there is no need to ever check the
> return value.  The function can work or not, but the code logic should
> never do something different based on this.
> 
> Cc: Jason Baron <jbaron@...mai.com>
> Cc: linux-kernel@...r.kernel.org
> Signed-off-by: Greg Kroah-Hartman <gregkh@...uxfoundation.org>
> ---
>  lib/dynamic_debug.c | 12 +++---------
>  1 file changed, 3 insertions(+), 9 deletions(-)
> 
> diff --git a/lib/dynamic_debug.c b/lib/dynamic_debug.c
> index 8a16c2d498e9..c60409138e13 100644
> --- a/lib/dynamic_debug.c
> +++ b/lib/dynamic_debug.c
> @@ -993,20 +993,14 @@ static __initdata int ddebug_init_success;
>  
>  static int __init dynamic_debug_init_debugfs(void)
>  {
> -	struct dentry *dir, *file;
> +	struct dentry *dir;
>  
>  	if (!ddebug_init_success)
>  		return -ENODEV;
>  
>  	dir = debugfs_create_dir("dynamic_debug", NULL);
> -	if (!dir)
> -		return -ENOMEM;
> -	file = debugfs_create_file("control", 0644, dir, NULL,
> -					&ddebug_proc_fops);
> -	if (!file) {
> -		debugfs_remove(dir);
> -		return -ENOMEM;
> -	}
> +	debugfs_create_file("control", 0644, dir, NULL, &ddebug_proc_fops);
> +
>  	return 0;
>  }
>  
> 

Looks like debugfs_create_dir() can return NULL, and in that case if its
passed to debugfs_create_file() then the 'control' file ends up in the
root of debugfs? I think its better to just not create the file then
have it in the wrong place so maybe the file creation should be guarded
by if(IS_ERR_OR_NULL(dir)).

Thanks,

-Jason

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ