Linux wireless drivers development
 help / color / mirror / Atom feed
From: Leon Romanovsky <leon@kernel.org>
To: Yang Yingliang <yangyingliang@huawei.com>
Cc: linux-wireless@vger.kernel.org, netdev@vger.kernel.org,
	johannes@sipsolutions.net
Subject: Re: [PATCH -next] rfkill: remove BUG_ON() in core.c
Date: Sun, 23 Oct 2022 11:12:27 +0300	[thread overview]
Message-ID: <Y1T3a1y/pWdbt2ow@unreal> (raw)
In-Reply-To: <20221021130104.469966-1-yangyingliang@huawei.com>

On Fri, Oct 21, 2022 at 09:01:04PM +0800, Yang Yingliang wrote:
> Replace BUG_ON() with pointer check to handle fault more gracefully.
> 
> Signed-off-by: Yang Yingliang <yangyingliang@huawei.com>
> ---
>  net/rfkill/core.c | 29 ++++++++++++++---------------
>  1 file changed, 14 insertions(+), 15 deletions(-)
> 
> diff --git a/net/rfkill/core.c b/net/rfkill/core.c
> index dac4fdc7488a..5fc96fa24eda 100644
> --- a/net/rfkill/core.c
> +++ b/net/rfkill/core.c
> @@ -150,9 +150,8 @@ EXPORT_SYMBOL(rfkill_get_led_trigger_name);
>  
>  void rfkill_set_led_trigger_name(struct rfkill *rfkill, const char *name)
>  {
> -	BUG_ON(!rfkill);
> -
> -	rfkill->ledtrigname = name;
> +	if (rfkill)

In all these places, rfkill shouldn't be NULL from the beginning. By
adding these if (rfkill), you are saying to reviewers and code authors
that it is correct thing to do something like this
rfkill_set_led_trigger_name(NULL, "new_name"), which is of course not
true.

Thanks

      parent reply	other threads:[~2022-10-23  8:12 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-10-21 13:01 [PATCH -next] rfkill: remove BUG_ON() in core.c Yang Yingliang
2022-10-21 13:17 ` Johannes Berg
2022-10-23  8:12 ` Leon Romanovsky [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=Y1T3a1y/pWdbt2ow@unreal \
    --to=leon@kernel.org \
    --cc=johannes@sipsolutions.net \
    --cc=linux-wireless@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=yangyingliang@huawei.com \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox