From: Zijun Hu <quic_zijuhu@quicinc.com>
To: <johannes@sipsolutions.net>, <davem@davemloft.net>,
<edumazet@google.com>, <kuba@kernel.org>, <pabeni@redhat.com>,
<emmanuel.grumbach@intel.com>
Cc: <linux-wireless@vger.kernel.org>, <netdev@vger.kernel.org>,
Zijun Hu <quic_zijuhu@quicinc.com>
Subject: [PATCH v1 1/2] net: rfkill: Fix a wrongly handling error case
Date: Fri, 7 Jun 2024 22:40:11 +0800 [thread overview]
Message-ID: <1717771212-30723-2-git-send-email-quic_zijuhu@quicinc.com> (raw)
In-Reply-To: <1717771212-30723-1-git-send-email-quic_zijuhu@quicinc.com>
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 <quic_zijuhu@quicinc.com>
---
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
next prev parent reply other threads:[~2024-06-07 14:40 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-06-07 14:40 [PATCH v1 0/2] net: rfkill: Fix 2 bugs within rfkill_set_hw_state_reason() Zijun Hu
2024-06-07 14:40 ` Zijun Hu [this message]
2024-06-12 8:15 ` [PATCH v1 1/2] net: rfkill: Fix a wrongly handling error case Johannes Berg
2024-06-12 10:12 ` quic_zijuhu
2024-06-12 10:14 ` Johannes Berg
2024-06-07 14:40 ` [PATCH v1 2/2] net: rfkill: Fix a logic error within rfkill_set_hw_state_reason() Zijun Hu
2024-06-12 8:18 ` Johannes Berg
2024-06-12 9:43 ` quic_zijuhu
2024-06-12 10:10 ` Johannes Berg
2024-06-12 10:11 ` Johannes Berg
2024-06-12 10:18 ` Johannes Berg
2024-06-12 10:35 ` quic_zijuhu
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=1717771212-30723-2-git-send-email-quic_zijuhu@quicinc.com \
--to=quic_zijuhu@quicinc.com \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=emmanuel.grumbach@intel.com \
--cc=johannes@sipsolutions.net \
--cc=kuba@kernel.org \
--cc=linux-wireless@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.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