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]
Date:   Wed, 23 Jan 2019 14:58:22 +0200
From:   Gilad Ben-Yossef <gilad@...yossef.com>
To:     Greg Kroah-Hartman <gregkh@...uxfoundation.org>
Cc:     Herbert Xu <herbert@...dor.apana.org.au>,
        David Miller <davem@...emloft.net>,
        Linux kernel mailing list <linux-kernel@...r.kernel.org>,
        Linux Crypto Mailing List <linux-crypto@...r.kernel.org>,
        Yael Chemla <yael.chemla@...s.arm.com>
Subject: Re: [PATCH 2/7] crypto: ccrree: no need to check return value of
 debugfs_create functions

Hi,

On Tue, Jan 22, 2019 at 5:14 PM Greg Kroah-Hartman
<gregkh@...uxfoundation.org> 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.



I get the part about not failing loading the driver just because some
debugs entry isn't available,  but wont it be weird if
debugfs_create_dir() fails but  debugfs_create_regset32() succeeds and
we suddenly have weird files in the debugfs root dir?
Not the end of the world of course but maybe it's better to avoid
trying to create the files if the directory is not available?

Thanks,
Gilad

>
> Cc: Yael Chemla <yael.chemla@...s.arm.com>
> Cc: Gilad Ben-Yossef <gilad@...yossef.com>
> Cc: Herbert Xu <herbert@...dor.apana.org.au>
> Cc: "David S. Miller" <davem@...emloft.net>
> Cc: linux-crypto@...r.kernel.org
> Signed-off-by: Greg Kroah-Hartman <gregkh@...uxfoundation.org>
> ---
>  drivers/crypto/ccree/cc_debugfs.c | 22 +++-------------------
>  drivers/crypto/ccree/cc_debugfs.h |  8 ++------
>  drivers/crypto/ccree/cc_driver.c  |  7 +------
>  3 files changed, 6 insertions(+), 31 deletions(-)
>
> diff --git a/drivers/crypto/ccree/cc_debugfs.c b/drivers/crypto/ccree/cc_debugfs.c
> index 5ca184e42483..5fa05a7bcf36 100644
> --- a/drivers/crypto/ccree/cc_debugfs.c
> +++ b/drivers/crypto/ccree/cc_debugfs.c
> @@ -39,11 +39,9 @@ static struct debugfs_reg32 debug_regs[] = {
>         CC_DEBUG_REG(AXIM_MON_COMP),
>  };
>
> -int __init cc_debugfs_global_init(void)
> +void __init cc_debugfs_global_init(void)
>  {
>         cc_debugfs_dir = debugfs_create_dir("ccree", NULL);
> -
> -       return !cc_debugfs_dir;
>  }
>
>  void __exit cc_debugfs_global_fini(void)
> @@ -56,7 +54,6 @@ int cc_debugfs_init(struct cc_drvdata *drvdata)
>         struct device *dev = drvdata_to_dev(drvdata);
>         struct cc_debugfs_ctx *ctx;
>         struct debugfs_regset32 *regset;
> -       struct dentry *file;
>
>         debug_regs[0].offset = drvdata->sig_offset;
>         debug_regs[1].offset = drvdata->ver_offset;
> @@ -74,22 +71,9 @@ int cc_debugfs_init(struct cc_drvdata *drvdata)
>         regset->base = drvdata->cc_base;
>
>         ctx->dir = debugfs_create_dir(drvdata->plat_dev->name, cc_debugfs_dir);
> -       if (!ctx->dir)
> -               return -ENFILE;
> -
> -       file = debugfs_create_regset32("regs", 0400, ctx->dir, regset);
> -       if (!file) {
> -               debugfs_remove(ctx->dir);
> -               return -ENFILE;
> -       }
>
> -       file = debugfs_create_bool("coherent", 0400, ctx->dir,
> -                                  &drvdata->coherent);
> -
> -       if (!file) {
> -               debugfs_remove_recursive(ctx->dir);
> -               return -ENFILE;
> -       }
> +       debugfs_create_regset32("regs", 0400, ctx->dir, regset);
> +       debugfs_create_bool("coherent", 0400, ctx->dir, &drvdata->coherent);
>
>         drvdata->debugfs = ctx;
>
> diff --git a/drivers/crypto/ccree/cc_debugfs.h b/drivers/crypto/ccree/cc_debugfs.h
> index 5b5320eca7d2..01cbd9a95659 100644
> --- a/drivers/crypto/ccree/cc_debugfs.h
> +++ b/drivers/crypto/ccree/cc_debugfs.h
> @@ -5,7 +5,7 @@
>  #define __CC_DEBUGFS_H__
>
>  #ifdef CONFIG_DEBUG_FS
> -int cc_debugfs_global_init(void);
> +void cc_debugfs_global_init(void);
>  void cc_debugfs_global_fini(void);
>
>  int cc_debugfs_init(struct cc_drvdata *drvdata);
> @@ -13,11 +13,7 @@ void cc_debugfs_fini(struct cc_drvdata *drvdata);
>
>  #else
>
> -static inline int cc_debugfs_global_init(void)
> -{
> -       return 0;
> -}
> -
> +static inline void cc_debugfs_global_init(void) {}
>  static inline void cc_debugfs_global_fini(void) {}
>
>  static inline int cc_debugfs_init(struct cc_drvdata *drvdata)
> diff --git a/drivers/crypto/ccree/cc_driver.c b/drivers/crypto/ccree/cc_driver.c
> index 8ada308d72ee..662738e53ced 100644
> --- a/drivers/crypto/ccree/cc_driver.c
> +++ b/drivers/crypto/ccree/cc_driver.c
> @@ -538,13 +538,8 @@ static struct platform_driver ccree_driver = {
>
>  static int __init ccree_init(void)
>  {
> -       int ret;
> -
>         cc_hash_global_init();
> -
> -       ret = cc_debugfs_global_init();
> -       if (ret)
> -               return ret;
> +       cc_debugfs_global_init();
>
>         return platform_driver_register(&ccree_driver);
>  }
> --
> 2.20.1
>


-- 
Gilad Ben-Yossef
Chief Coffee Drinker

values of β will give rise to dom!

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ