diff mbox

[1/2] cfg80211: regulatory, reset regdomain in case of error

Message ID 1392364441-4640-1-git-send-email-janusz.dziedzic@tieto.com (mailing list archive)
State Not Applicable, archived
Headers show

Commit Message

Janusz.Dziedzic@tieto.com Feb. 14, 2014, 7:54 a.m. UTC
Reset regdomain to world regdomain in case
of errors in set_regdom() function.

This will fix a problem with such scenario:
- iw reg set US
- iw reg set 00
- iw reg set US
The last step always fail and we get deadlock
in kernel regulatory code. Next setting new
regulatory wasn't possible due to:

Pending regulatory request, waiting for it to be processed...

Signed-off-by: Janusz Dziedzic <janusz.dziedzic@tieto.com>
---
 net/wireless/reg.c |   10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

Comments

Johannes Berg Feb. 21, 2014, 8:55 a.m. UTC | #1
On Fri, 2014-02-14 at 08:54 +0100, Janusz Dziedzic wrote:
> Reset regdomain to world regdomain in case
> of errors in set_regdom() function.

Luis, please comment?

johannes

--
To unsubscribe from this list: send the line "unsubscribe linux-wireless" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Luis R. Rodriguez Feb. 22, 2014, 12:22 a.m. UTC | #2
On Thu, Feb 13, 2014 at 11:54 PM, Janusz Dziedzic
<janusz.dziedzic@tieto.com> wrote:
> Reset regdomain to world regdomain in case
> of errors in set_regdom() function.
>
> This will fix a problem with such scenario:
> - iw reg set US
> - iw reg set 00
> - iw reg set US
> The last step always fail and we get deadlock
> in kernel regulatory code. Next setting new
> regulatory wasn't possible due to:
>
> Pending regulatory request, waiting for it to be processed...
>
> Signed-off-by: Janusz Dziedzic <janusz.dziedzic@tieto.com>

Acked-by: Luis R. Rodriguez <mcgrof@do-not-panic.com>

  Luis
--
To unsubscribe from this list: send the line "unsubscribe linux-wireless" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/net/wireless/reg.c b/net/wireless/reg.c
index c80f20e..c4c3af1 100644
--- a/net/wireless/reg.c
+++ b/net/wireless/reg.c
@@ -2504,6 +2504,7 @@  static int reg_set_rd_country_ie(const struct ieee80211_regdomain *rd,
 int set_regdom(const struct ieee80211_regdomain *rd)
 {
 	struct regulatory_request *lr;
+	bool user_reset = false;
 	int r;
 
 	if (!reg_is_valid_request(rd->alpha2)) {
@@ -2520,6 +2521,7 @@  int set_regdom(const struct ieee80211_regdomain *rd)
 		break;
 	case NL80211_REGDOM_SET_BY_USER:
 		r = reg_set_rd_user(rd, lr);
+		user_reset = true;
 		break;
 	case NL80211_REGDOM_SET_BY_DRIVER:
 		r = reg_set_rd_driver(rd, lr);
@@ -2533,8 +2535,14 @@  int set_regdom(const struct ieee80211_regdomain *rd)
 	}
 
 	if (r) {
-		if (r == -EALREADY)
+		switch (r) {
+		case -EALREADY:
 			reg_set_request_processed();
+			break;
+		default:
+			/* Back to world regulatory in case of errors */
+			restore_regulatory_settings(user_reset);
+		}
 
 		kfree(rd);
 		return r;