Search Linux Wireless

[PATCH -next] rfkill: replace BUG_ON() with WARN_ON() in core.c

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Replace BUG_ON() with WARN_ON() to handle fault more gracefully.

Suggested-by: Johannes Berg <johannes@xxxxxxxxxxxxxxxx>
Signed-off-by: Yang Yingliang <yangyingliang@xxxxxxxxxx>
---
 net/rfkill/core.c | 25 ++++++++++++++++---------
 1 file changed, 16 insertions(+), 9 deletions(-)

diff --git a/net/rfkill/core.c b/net/rfkill/core.c
index dac4fdc7488a..4f493e76520d 100644
--- a/net/rfkill/core.c
+++ b/net/rfkill/core.c
@@ -150,7 +150,8 @@ EXPORT_SYMBOL(rfkill_get_led_trigger_name);
 
 void rfkill_set_led_trigger_name(struct rfkill *rfkill, const char *name)
 {
-	BUG_ON(!rfkill);
+	if (WARN_ON(!rfkill))
+		return;
 
 	rfkill->ledtrigname = name;
 }
@@ -532,7 +533,8 @@ bool rfkill_set_hw_state_reason(struct rfkill *rfkill,
 	unsigned long flags;
 	bool ret, prev;
 
-	BUG_ON(!rfkill);
+	if (WARN_ON(!rfkill))
+		return blocked;
 
 	if (WARN(reason &
 	    ~(RFKILL_HARD_BLOCK_SIGNAL | RFKILL_HARD_BLOCK_NOT_OWNER),
@@ -581,7 +583,8 @@ bool rfkill_set_sw_state(struct rfkill *rfkill, bool blocked)
 	unsigned long flags;
 	bool prev, hwblock;
 
-	BUG_ON(!rfkill);
+	if (WARN_ON(!rfkill))
+		return blocked;
 
 	spin_lock_irqsave(&rfkill->lock, flags);
 	prev = !!(rfkill->state & RFKILL_BLOCK_SW);
@@ -607,8 +610,8 @@ void rfkill_init_sw_state(struct rfkill *rfkill, bool blocked)
 {
 	unsigned long flags;
 
-	BUG_ON(!rfkill);
-	BUG_ON(rfkill->registered);
+	if (WARN_ON(!rfkill) || WARN_ON(rfkill->registered))
+		return;
 
 	spin_lock_irqsave(&rfkill->lock, flags);
 	__rfkill_set_sw_state(rfkill, blocked);
@@ -622,7 +625,8 @@ void rfkill_set_states(struct rfkill *rfkill, bool sw, bool hw)
 	unsigned long flags;
 	bool swprev, hwprev;
 
-	BUG_ON(!rfkill);
+	if (WARN_ON(!rfkill))
+		return;
 
 	spin_lock_irqsave(&rfkill->lock, flags);
 
@@ -860,7 +864,8 @@ static int rfkill_dev_uevent(struct device *dev, struct kobj_uevent_env *env)
 
 void rfkill_pause_polling(struct rfkill *rfkill)
 {
-	BUG_ON(!rfkill);
+	if (WARN_ON(!rfkill))
+		return;
 
 	if (!rfkill->ops->poll)
 		return;
@@ -872,7 +877,8 @@ EXPORT_SYMBOL(rfkill_pause_polling);
 
 void rfkill_resume_polling(struct rfkill *rfkill)
 {
-	BUG_ON(!rfkill);
+	if (WARN_ON(!rfkill))
+		return;
 
 	if (!rfkill->ops->poll)
 		return;
@@ -1115,7 +1121,8 @@ EXPORT_SYMBOL(rfkill_register);
 
 void rfkill_unregister(struct rfkill *rfkill)
 {
-	BUG_ON(!rfkill);
+	if (WARN_ON(!rfkill))
+		return;
 
 	if (rfkill->ops->poll)
 		cancel_delayed_work_sync(&rfkill->poll_work);
-- 
2.25.1




[Index of Archives]     [Linux Host AP]     [ATH6KL]     [Linux Wireless Personal Area Network]     [Linux Bluetooth]     [Wireless Regulations]     [Linux Netdev]     [Kernel Newbies]     [Linux Kernel]     [IDE]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite Hiking]     [MIPS Linux]     [ARM Linux]     [Linux RAID]

  Powered by Linux