Thread (12 messages) 12 messages, 2 authors, 2024-06-12

[PATCH v1 1/2] net: rfkill: Fix a wrongly handling error case

From: Zijun Hu <hidden>
Date: 2024-06-07 14:40:48
Also in: netdev
Subsystem: rfkill, the rest · Maintainers: Johannes Berg, Linus Torvalds

Kernel API rfkill_set_hw_state_reason() does not return current combined
block state when its parameter @reason is invalid, that is wrong according
to its comments.

Fixed by returning API required value, also use pr_err() instead of WARN()
for this error case handling.

Fixes: 14486c82612a ("rfkill: add a reason to the HW rfkill state")
Signed-off-by: Zijun Hu <redacted>
---
 net/rfkill/core.c | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)
diff --git a/net/rfkill/core.c b/net/rfkill/core.c
index c3feb4f49d09..0dc982b4fce6 100644
--- a/net/rfkill/core.c
+++ b/net/rfkill/core.c
@@ -543,13 +543,15 @@ bool rfkill_set_hw_state_reason(struct rfkill *rfkill,
 {
 	unsigned long flags;
 	bool ret, prev;
+	const unsigned long reason_mask = RFKILL_HARD_BLOCK_SIGNAL |
+		RFKILL_HARD_BLOCK_NOT_OWNER;
 
 	BUG_ON(!rfkill);
 
-	if (WARN(reason &
-	    ~(RFKILL_HARD_BLOCK_SIGNAL | RFKILL_HARD_BLOCK_NOT_OWNER),
-	    "hw_state reason not supported: 0x%lx", reason))
-		return blocked;
+	if (reason & ~reason_mask) {
+		pr_err("hw_state reason not supported: 0x%lx\n", reason);
+		return rfkill_blocked(rfkill);
+	}
 
 	spin_lock_irqsave(&rfkill->lock, flags);
 	prev = !!(rfkill->hard_block_reasons & reason);
-- 
2.7.4
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help