[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <Y1T3a1y/pWdbt2ow@unreal>
Date: Sun, 23 Oct 2022 11:12:27 +0300
From: Leon Romanovsky <leon@...nel.org>
To: Yang Yingliang <yangyingliang@...wei.com>
Cc: linux-wireless@...r.kernel.org, netdev@...r.kernel.org,
johannes@...solutions.net
Subject: Re: [PATCH -next] rfkill: remove BUG_ON() in core.c
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@...wei.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
Powered by blists - more mailing lists