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] [day] [month] [year] [list]
Date:   Sun, 15 Dec 2019 20:08:49 +0100
From:   Greg Kroah-Hartman <gregkh@...uxfoundation.org>
To:     Aditya Pakki <pakki001@....edu>
Cc:     kjlu@....edu, Mark Brown <broonie@...nel.org>,
        "Rafael J. Wysocki" <rafael@...nel.org>,
        linux-kernel@...r.kernel.org
Subject: Re: [PATCH] regmap: replace multiple BUG_ON assertions with error
 return code

On Sun, Dec 15, 2019 at 12:39:52PM -0600, Aditya Pakki wrote:
> Various register operations check for the validity of cache_ops
> struct and crash in case of failure. However, by returning the error
> to the callers, instead of assert, these functions can avoid the crash.
> 
> Signed-off-by: Aditya Pakki <pakki001@....edu>
> ---
>  drivers/base/regmap/regcache.c | 12 ++++++++----
>  1 file changed, 8 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/base/regmap/regcache.c b/drivers/base/regmap/regcache.c
> index a93cafd7be4f..855fa25ae595 100644
> --- a/drivers/base/regmap/regcache.c
> +++ b/drivers/base/regmap/regcache.c
> @@ -238,7 +238,8 @@ int regcache_read(struct regmap *map,
>  	if (map->cache_type == REGCACHE_NONE)
>  		return -ENOSYS;
>  
> -	BUG_ON(!map->cache_ops);
> +	if (!map->cache_ops)
> +		return -EINVAL;

While it is fun to make patches like this, again, if you can prove that
this can never happen, just remove the check please.

And if it can happen, why is -EINVAL the correct error code here?

thanks,

greg k-h

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ