From patchwork Wed Jun 5 14:34:50 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Antonio Quartulli X-Patchwork-Id: 2670361 Return-Path: X-Original-To: patchwork-linux-wireless@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork1.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork1.kernel.org (Postfix) with ESMTP id 3EC3D40077 for ; Wed, 5 Jun 2013 14:36:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756106Ab3FEOgx (ORCPT ); Wed, 5 Jun 2013 10:36:53 -0400 Received: from diserzione.investici.org ([82.221.99.153]:39623 "EHLO diserzione.investici.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756098Ab3FEOgx (ORCPT ); Wed, 5 Jun 2013 10:36:53 -0400 Received: from [82.221.99.153] (diserzione [82.221.99.153]) (Authenticated sender: ordex@autistici.org) by localhost (Postfix) with ESMTPSA id DFFE5180DD0; Wed, 5 Jun 2013 14:36:49 +0000 (UTC) X-DKIM: Sendmail DKIM Filter v2.8.2 diserzione.investici.org DFFE5180DD0 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=autistici.org; s=stigmate; t=1370443011; bh=ltek1/6UHIGkWVUNf7R6n8gh8l6fzcajQC2ejH4NZ6s=; h=From:To:Cc:Subject:Date:Message-Id; b=O2ldR1wp5jb8qxda6nmqnGuJgOv85ar35RbC4uh9morxqh5CsmFtcpFRlJSJxjg78 zKFxv7IrXGYNsHgfRdATBFFp0ujUb9sy4OWn/LDKgfhD4ED7RIpg0LnLadqW35yyw2 eq4obJYsYIphpHHt/Npj25b39Ui0oBlzn20ztI8k= From: Antonio Quartulli To: Johannes Berg Cc: linux-wireless@vger.kernel.org, Antonio Quartulli Subject: [PATCHv3 1/4] mac80211: make mgmt_tx accept a NULL channel Date: Wed, 5 Jun 2013 16:34:50 +0200 Message-Id: <1370442893-1687-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(); }