All of lore.kernel.org
 help / color / mirror / Atom feed
From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
To: Aditya Pakki <pakki001@umn.edu>
Cc: kjlu@umn.edu, Mark Brown <broonie@kernel.org>,
	"Rafael J. Wysocki" <rafael@kernel.org>,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH] regmap: replace multiple BUG_ON assertions with error return code
Date: Sun, 15 Dec 2019 20:08:49 +0100	[thread overview]
Message-ID: <20191215190849.GA914378@kroah.com> (raw)
In-Reply-To: <20191215183952.689-1-pakki001@umn.edu>

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@umn.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

      reply	other threads:[~2019-12-15 19:08 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-12-15 18:39 [PATCH] regmap: replace multiple BUG_ON assertions with error return code Aditya Pakki
2019-12-15 19:08 ` Greg Kroah-Hartman [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20191215190849.GA914378@kroah.com \
    --to=gregkh@linuxfoundation.org \
    --cc=broonie@kernel.org \
    --cc=kjlu@umn.edu \
    --cc=linux-kernel@vger.kernel.org \
    --cc=pakki001@umn.edu \
    --cc=rafael@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.