From patchwork Tue Jun 11 12:20:00 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Antonio Quartulli X-Patchwork-Id: 2703051 Return-Path: X-Original-To: patchwork-linux-wireless@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork2.kernel.org (Postfix) with ESMTP id 9452BDF23A for ; Tue, 11 Jun 2013 12:22:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754687Ab3FKMWH (ORCPT ); Tue, 11 Jun 2013 08:22:07 -0400 Received: from contumacia.investici.org ([178.255.144.35]:52831 "EHLO contumacia.investici.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753090Ab3FKMWF (ORCPT ); Tue, 11 Jun 2013 08:22:05 -0400 Received: from [178.255.144.35] (contumacia [178.255.144.35]) (Authenticated sender: ordex@autistici.org) by localhost (Postfix) with ESMTPSA id 340C5E813E; Tue, 11 Jun 2013 12:22:02 +0000 (UTC) X-DKIM: Sendmail DKIM Filter v2.8.2 contumacia.investici.org 340C5E813E DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=autistici.org; s=stigmate; t=1370953322; bh=ltek1/6UHIGkWVUNf7R6n8gh8l6fzcajQC2ejH4NZ6s=; h=From:To:Cc:Subject:Date:Message-Id; b=g3h0L185I8wa1OD0m+9mvWI1VYlHCWqBy5Xhkp+NTTxaOK+yj/1Uf1ZeeyXzeMDhf NkM6lP/Cx5sA+GFBVmWa0zjDH0WUpKXLjgA3L58lCb93TAlzWAT3NuqB0cWEjBvYoP elnt0ejt4ev7usJ5KB2sXaYnmZtNGMaNaQDFQhng= From: Antonio Quartulli To: Johannes Berg Cc: linux-wireless@vger.kernel.org, Antonio Quartulli Subject: [PATCHv5 1/4] mac80211: make mgmt_tx accept a NULL channel Date: Tue, 11 Jun 2013 14:20:00 +0200 Message-Id: <1370953203-4086-1-git-send-email-ordex@autistici.org> X-Mailer: git-send-email 1.8.1.5 Sender: linux-wireless-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org From: Antonio Quartulli cfg80211 passes a NULL channel to mgmt_tx if the frame has to be sent on the one currently in use by the device. Make the implementation of mgmt_tx correctly handle this case. Fail if offchan is required. Signed-off-by: Antonio Quartulli --- net/mac80211/cfg.c | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/net/mac80211/cfg.c b/net/mac80211/cfg.c index 3062210..617c5c8 100644 --- a/net/mac80211/cfg.c +++ b/net/mac80211/cfg.c @@ -2838,6 +2838,12 @@ static int ieee80211_mgmt_tx(struct wiphy *wiphy, struct wireless_dev *wdev, return -EOPNOTSUPP; } + /* configurations requiring offchan cannot work if no channel has been + * specified + */ + if (need_offchan && !chan) + return -EINVAL; + mutex_lock(&local->mtx); /* Check if the operating channel is the requested channel */ @@ -2847,10 +2853,14 @@ static int ieee80211_mgmt_tx(struct wiphy *wiphy, struct wireless_dev *wdev, rcu_read_lock(); chanctx_conf = rcu_dereference(sdata->vif.chanctx_conf); - if (chanctx_conf) - need_offchan = chan != chanctx_conf->def.chan; - else + if (chanctx_conf) { + need_offchan = chan && (chan != chanctx_conf->def.chan); + } else if (!chan) { + ret = -EINVAL; + goto out_unlock; + } else { need_offchan = true; + } rcu_read_unlock(); }