From patchwork Tue Sep 11 13:26:16 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johannes Berg X-Patchwork-Id: 1437991 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 35A89DFAF3 for ; Tue, 11 Sep 2012 13:25:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754748Ab2IKNZv (ORCPT ); Tue, 11 Sep 2012 09:25:51 -0400 Received: from he.sipsolutions.net ([78.46.109.217]:40294 "EHLO sipsolutions.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753760Ab2IKNZt (ORCPT ); Tue, 11 Sep 2012 09:25:49 -0400 Received: by sipsolutions.net with esmtpsa (TLS1.2:DHE_RSA_AES_256_CBC_SHA256:256) (Exim 4.80) (envelope-from ) id 1TBQTL-0007Jk-Kr; Tue, 11 Sep 2012 15:25:47 +0200 From: Johannes Berg To: linux-wireless@vger.kernel.org Cc: Johannes Berg Subject: [RFC v2 05/12] mac80211: check channel context methods Date: Tue, 11 Sep 2012 15:26:16 +0200 Message-Id: <1347369983-12459-6-git-send-email-johannes@sipsolutions.net> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1347369983-12459-1-git-send-email-johannes@sipsolutions.net> References: <1347369983-12459-1-git-send-email-johannes@sipsolutions.net> Sender: linux-wireless-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org From: Johannes Berg Verify that the channel context methods are all assigned by the driver or not used. Signed-off-by: Johannes Berg --- net/mac80211/main.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/net/mac80211/main.c b/net/mac80211/main.c index 9be3ef1..d709a5d 100644 --- a/net/mac80211/main.c +++ b/net/mac80211/main.c @@ -549,6 +549,13 @@ struct ieee80211_hw *ieee80211_alloc_hw(size_t priv_data_len, if (WARN_ON(ops->sta_state && (ops->sta_add || ops->sta_remove))) return NULL; + /* check all or no channel context operations exist */ + i = !!ops->add_chanctx + !!ops->remove_chanctx + + !!ops->change_chanctx + !!ops->assign_vif_chanctx + + !!ops->unassign_vif_chanctx; + if (WARN_ON(i != 0 && i != 5)) + return NULL; + /* Ensure 32-byte alignment of our private data and hw private data. * We use the wiphy priv data for both our ieee80211_local and for * the driver's private data