diff mbox series

[v3] wifi: cfg80211: Set the channel definition for the different Wi-Fi modes when starting CAC

Message ID 20240816142418.3381951-1-ih@simonwunderlich.de
State Superseded
Headers show
Series [v3] wifi: cfg80211: Set the channel definition for the different Wi-Fi modes when starting CAC | expand

Commit Message

Issam Hamdi Aug. 16, 2024, 2:24 p.m. UTC
When starting CAC in a mode other than AP mode, it return a
"WARNING: CPU: 0 PID: 63 at cfg80211_chandef_dfs_usable+0x20/0xaf [cfg80211]"
caused by the chandef.chan being null at the end of CAC.

Solution: Ensure the channel definition is set for the different modes
when starting CAC to avoid getting a NULL 'chan' at the end of CAC.

 Call Trace:
  ? show_regs.part.0+0x14/0x16
  ? __warn+0x67/0xc0
  ? cfg80211_chandef_dfs_usable+0x20/0xaf [cfg80211]
  ? report_bug+0xa7/0x130
  ? exc_overflow+0x30/0x30
  ? handle_bug+0x27/0x50
  ? exc_invalid_op+0x18/0x60
  ? handle_exception+0xf6/0xf6
  ? exc_overflow+0x30/0x30
  ? cfg80211_chandef_dfs_usable+0x20/0xaf [cfg80211]
  ? exc_overflow+0x30/0x30
  ? cfg80211_chandef_dfs_usable+0x20/0xaf [cfg80211]
  ? regulatory_propagate_dfs_state.cold+0x1b/0x4c [cfg80211]
  ? cfg80211_propagate_cac_done_wk+0x1a/0x30 [cfg80211]
  ? process_one_work+0x165/0x280
  ? worker_thread+0x120/0x3f0
  ? kthread+0xc2/0xf0
  ? process_one_work+0x280/0x280
  ? kthread_complete_and_exit+0x20/0x20
  ? ret_from_fork+0x19/0x24

Reported-by: Kretschmer Mathias <mathias.kretschmer@fit.fraunhofer.de>
Signed-off-by: Issam Hamdi <ih@simonwunderlich.de>
---
v2: update the subject
v3: update the second Signed-off-by to Reported-by
---
 net/wireless/nl80211.c | 18 +++++++++++++++++-
 1 file changed, 17 insertions(+), 1 deletion(-)


base-commit: cc32e9fb380d8afdbf3486d7063d5520bfb0f071

Comments

Johannes Berg Aug. 23, 2024, 10:42 a.m. UTC | #1
On Fri, 2024-08-16 at 16:24 +0200, Issam Hamdi wrote:
> 
> @@ -10143,7 +10143,23 @@ static int nl80211_start_radar_detection(struct sk_buff *skb,
>  
>  	err = rdev_start_radar_detection(rdev, dev, &chandef, cac_time_ms);
>  	if (!err) {
> -		wdev->links[0].ap.chandef = chandef;
> +		switch (wdev->iftype) {
> +		case NL80211_IFTYPE_MESH_POINT:
> +			wdev->u.mesh.chandef = chandef;
> +			break;
> +		case NL80211_IFTYPE_ADHOC:
> +			wdev->u.ibss.chandef = chandef;
> +			break;
> +		case NL80211_IFTYPE_OCB:
> +			wdev->u.ocb.chandef = chandef;
> +			break;
> 

OCB cannot even get to this code given earlier conditions, why are you
adding it here?


I guess this should conflict:

https://lore.kernel.org/linux-wireless/20240711035147.1896538-1-quic_adisi@quicinc.com/

but it's probably not too hard to resolve that.

johannes
Issam Hamdi Aug. 26, 2024, 9:51 a.m. UTC | #2
Hello,

On 8/23/24 12:42, Johannes Berg wrote:
> On Fri, 2024-08-16 at 16:24 +0200, Issam Hamdi wrote:
>> @@ -10143,7 +10143,23 @@ static int nl80211_start_radar_detection(struct sk_buff *skb,
>>   
>>   	err = rdev_start_radar_detection(rdev, dev, &chandef, cac_time_ms);
>>   	if (!err) {
>> -		wdev->links[0].ap.chandef = chandef;
>> +		switch (wdev->iftype) {
>> +		case NL80211_IFTYPE_MESH_POINT:
>> +			wdev->u.mesh.chandef = chandef;
>> +			break;
>> +		case NL80211_IFTYPE_ADHOC:
>> +			wdev->u.ibss.chandef = chandef;
>> +			break;
>> +		case NL80211_IFTYPE_OCB:
>> +			wdev->u.ocb.chandef = chandef;
>> +			break;
>>
> OCB cannot even get to this code given earlier conditions, why are you
> adding it here?

Actually I didn't test it with OCB mode, I added the check on the 
different modes to make sure that the function "wdev_chandef" return a 
no NULL chandef for the different modes.

I will remove the check on the OCB mode, if it will impact other 
implementation.

>
> I guess this should conflict:
>
> https://lore.kernel.org/linux-wireless/20240711035147.1896538-1-quic_adisi@quicinc.com/
>
> but it's probably not too hard to resolve that.
>
> johannes
Issam
diff mbox series

Patch

diff --git a/net/wireless/nl80211.c b/net/wireless/nl80211.c
index 7397a372c78e..36ae2594753e 100644
--- a/net/wireless/nl80211.c
+++ b/net/wireless/nl80211.c
@@ -10143,7 +10143,23 @@  static int nl80211_start_radar_detection(struct sk_buff *skb,
 
 	err = rdev_start_radar_detection(rdev, dev, &chandef, cac_time_ms);
 	if (!err) {
-		wdev->links[0].ap.chandef = chandef;
+		switch (wdev->iftype) {
+		case NL80211_IFTYPE_MESH_POINT:
+			wdev->u.mesh.chandef = chandef;
+			break;
+		case NL80211_IFTYPE_ADHOC:
+			wdev->u.ibss.chandef = chandef;
+			break;
+		case NL80211_IFTYPE_OCB:
+			wdev->u.ocb.chandef = chandef;
+			break;
+		case NL80211_IFTYPE_AP:
+		case NL80211_IFTYPE_P2P_GO:
+			wdev->links[0].ap.chandef = chandef;
+			break;
+		default:
+			break;
+		}
 		wdev->cac_started = true;
 		wdev->cac_start_time = jiffies;
 		wdev->cac_time_ms = cac_time_ms;