netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] net: rtlwifi: Use pr_warn_once instead of WARN_ONCE
@ 2022-05-10  9:25 Dongliang Mu
  2022-05-10 15:36 ` Kalle Valo
  0 siblings, 1 reply; 3+ messages in thread
From: Dongliang Mu @ 2022-05-10  9:25 UTC (permalink / raw)
  To: Ping-Ke Shih, Kalle Valo, David S. Miller, Eric Dumazet,
	Jakub Kicinski, Paolo Abeni
  Cc: Dongliang Mu, linux-wireless, netdev, linux-kernel

From: Dongliang Mu <mudongliangabcd@gmail.com>

This memory allocation failure can be triggered by fault injection or
high pressure testing, resulting a WARN.

Fix this by replacing WARN with pr_warn_once.

Signed-off-by: Dongliang Mu <mudongliangabcd@gmail.com>
---
 drivers/net/wireless/realtek/rtlwifi/usb.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/wireless/realtek/rtlwifi/usb.c b/drivers/net/wireless/realtek/rtlwifi/usb.c
index 86a236873254..acb0c15e9748 100644
--- a/drivers/net/wireless/realtek/rtlwifi/usb.c
+++ b/drivers/net/wireless/realtek/rtlwifi/usb.c
@@ -1014,7 +1014,7 @@ int rtl_usb_probe(struct usb_interface *intf,
 	hw = ieee80211_alloc_hw(sizeof(struct rtl_priv) +
 				sizeof(struct rtl_usb_priv), &rtl_ops);
 	if (!hw) {
-		WARN_ONCE(true, "rtl_usb: ieee80211 alloc failed\n");
+		pr_warn_once("rtl_usb: ieee80211 alloc failed\n");
 		return -ENOMEM;
 	}
 	rtlpriv = hw->priv;
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] net: rtlwifi: Use pr_warn_once instead of WARN_ONCE
  2022-05-10  9:25 [PATCH] net: rtlwifi: Use pr_warn_once instead of WARN_ONCE Dongliang Mu
@ 2022-05-10 15:36 ` Kalle Valo
  2022-05-11  1:45   ` Dongliang Mu
  0 siblings, 1 reply; 3+ messages in thread
From: Kalle Valo @ 2022-05-10 15:36 UTC (permalink / raw)
  To: Dongliang Mu
  Cc: Ping-Ke Shih, David S. Miller, Eric Dumazet, Jakub Kicinski,
	Paolo Abeni, Dongliang Mu, linux-wireless, netdev, linux-kernel

Dongliang Mu <dzm91@hust.edu.cn> writes:

> From: Dongliang Mu <mudongliangabcd@gmail.com>
>
> This memory allocation failure can be triggered by fault injection or
> high pressure testing, resulting a WARN.
>
> Fix this by replacing WARN with pr_warn_once.
>
> Signed-off-by: Dongliang Mu <mudongliangabcd@gmail.com>
> ---
>  drivers/net/wireless/realtek/rtlwifi/usb.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/net/wireless/realtek/rtlwifi/usb.c b/drivers/net/wireless/realtek/rtlwifi/usb.c
> index 86a236873254..acb0c15e9748 100644
> --- a/drivers/net/wireless/realtek/rtlwifi/usb.c
> +++ b/drivers/net/wireless/realtek/rtlwifi/usb.c
> @@ -1014,7 +1014,7 @@ int rtl_usb_probe(struct usb_interface *intf,
>  	hw = ieee80211_alloc_hw(sizeof(struct rtl_priv) +
>  				sizeof(struct rtl_usb_priv), &rtl_ops);
>  	if (!hw) {
> -		WARN_ONCE(true, "rtl_usb: ieee80211 alloc failed\n");
> +		pr_warn_once("rtl_usb: ieee80211 alloc failed\n");
>  		return -ENOMEM;
>  	}
>  	rtlpriv = hw->priv;

I think we should warn every time ieee80211_alloc_hw() fails, it's
called only once per device initialisation, so pr_warn() is more
approriate.

-- 
https://patchwork.kernel.org/project/linux-wireless/list/

https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] net: rtlwifi: Use pr_warn_once instead of WARN_ONCE
  2022-05-10 15:36 ` Kalle Valo
@ 2022-05-11  1:45   ` Dongliang Mu
  0 siblings, 0 replies; 3+ messages in thread
From: Dongliang Mu @ 2022-05-11  1:45 UTC (permalink / raw)
  To: Kalle Valo
  Cc: Dongliang Mu, Ping-Ke Shih, David S. Miller, Eric Dumazet,
	Jakub Kicinski, Paolo Abeni, linux-wireless,
	open list:NETWORKING [GENERAL],
	linux-kernel

On Tue, May 10, 2022 at 11:37 PM Kalle Valo <kvalo@kernel.org> wrote:
>
> Dongliang Mu <dzm91@hust.edu.cn> writes:
>
> > From: Dongliang Mu <mudongliangabcd@gmail.com>
> >
> > This memory allocation failure can be triggered by fault injection or
> > high pressure testing, resulting a WARN.
> >
> > Fix this by replacing WARN with pr_warn_once.
> >
> > Signed-off-by: Dongliang Mu <mudongliangabcd@gmail.com>
> > ---
> >  drivers/net/wireless/realtek/rtlwifi/usb.c | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/drivers/net/wireless/realtek/rtlwifi/usb.c b/drivers/net/wireless/realtek/rtlwifi/usb.c
> > index 86a236873254..acb0c15e9748 100644
> > --- a/drivers/net/wireless/realtek/rtlwifi/usb.c
> > +++ b/drivers/net/wireless/realtek/rtlwifi/usb.c
> > @@ -1014,7 +1014,7 @@ int rtl_usb_probe(struct usb_interface *intf,
> >       hw = ieee80211_alloc_hw(sizeof(struct rtl_priv) +
> >                               sizeof(struct rtl_usb_priv), &rtl_ops);
> >       if (!hw) {
> > -             WARN_ONCE(true, "rtl_usb: ieee80211 alloc failed\n");
> > +             pr_warn_once("rtl_usb: ieee80211 alloc failed\n");
> >               return -ENOMEM;
> >       }
> >       rtlpriv = hw->priv;
>
> I think we should warn every time ieee80211_alloc_hw() fails, it's
> called only once per device initialisation, so pr_warn() is more
> approriate.

Yes, this is better. Already sent a v2 patch.

>
> --
> https://patchwork.kernel.org/project/linux-wireless/list/
>
> https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2022-05-11  1:46 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-05-10  9:25 [PATCH] net: rtlwifi: Use pr_warn_once instead of WARN_ONCE Dongliang Mu
2022-05-10 15:36 ` Kalle Valo
2022-05-11  1:45   ` Dongliang Mu

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).