From patchwork Wed Aug 5 10:15:24 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michal Kazior X-Patchwork-Id: 6947731 X-Patchwork-Delegate: kvalo@adurom.com Return-Path: X-Original-To: patchwork-linux-wireless@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id D54BEC05AC for ; Wed, 5 Aug 2015 10:15:01 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 06399203AC for ; Wed, 5 Aug 2015 10:15:01 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id EE9A820411 for ; Wed, 5 Aug 2015 10:14:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751829AbbHEKO6 (ORCPT ); Wed, 5 Aug 2015 06:14:58 -0400 Received: from mail-lb0-f180.google.com ([209.85.217.180]:35041 "EHLO mail-lb0-f180.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751445AbbHEKO4 (ORCPT ); Wed, 5 Aug 2015 06:14:56 -0400 Received: by lbbpo9 with SMTP id po9so21673209lbb.2 for ; Wed, 05 Aug 2015 03:14:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tieto.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=8SYNIKolPJhmTqHrg3k7+9OnpKq3EgpVv/pyEhXKeP4=; b=aQc9kq2pD8n4RLIS209a3LWGqYfKyYPEIx07BcDiyrNPK0VxdaFqmBVzKNDptkojB4 G+q0pD5/CLT1J9XjnmdZ14U4DLsdbl0c5QaHJXS56mFMEHW0d3MgHylNuFNJNEe94rUz vwG0vYpb6JgSkZxJ9W4AuULCTeSRV3KB/pBjc= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=8SYNIKolPJhmTqHrg3k7+9OnpKq3EgpVv/pyEhXKeP4=; b=jgDqAORajBlZRQcksEMjL5nmMYMgcgFXfCIXNcLJCQ3uUujVAFWolc/hDQSZovzsSp JdySeA6A+zjaO7VbUZSg9gHIJpT8mh1TRt3o3r/eGxtB4d1WEdQtgO3hTTIkr/pMm6d9 e+/q6TunD5/U6Comn7UI99AvU9xXiU4D23okzHB25hk335sMEhorGIzsTB/ON31U24Y0 cjcIpufZhrfL1erCQam4BBj1hFW1zSVp3OoKQ1n8byvQ8AtY5JhVq3Lp3GDqxPvE0nnG 9yHaKzlkhrXt6p9y5aqzNcJZ/ZxVmU43hh4tupFw5RwZucGcsPZLHrkXkVLXOJvgoYLR w5xw== X-Gm-Message-State: ALoCoQlPQvRCp3FNp7/fRykvc+LNSlje0ZRv9dj1QgfnSV7ieWc63yt9X+hQ+iahUbYLxJNEEDdUdj8oKIPaxfyWpDdSB5dEnzh9cUqSKMBPUzqlVKABVArl303HgR00D4kABhXJzs1h X-Received: by 10.152.44.230 with SMTP id h6mr8605293lam.21.1438769695224; Wed, 05 Aug 2015 03:14:55 -0700 (PDT) Received: from localhost.localdomain ([91.198.246.10]) by smtp.gmail.com with ESMTPSA id si3sm445460lbb.32.2015.08.05.03.14.54 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 05 Aug 2015 03:14:54 -0700 (PDT) From: Michal Kazior To: ath10k@lists.infradead.org Cc: linux-wireless@vger.kernel.org, Michal Kazior Subject: [PATCH 2/2] ath10k: fix peer limit enforcement Date: Wed, 5 Aug 2015 12:15:24 +0200 Message-Id: <1438769724-29438-2-git-send-email-michal.kazior@tieto.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1438769724-29438-1-git-send-email-michal.kazior@tieto.com> References: <1438769724-29438-1-git-send-email-michal.kazior@tieto.com> X-DomainID: tieto.com Sender: linux-wireless-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,RP_MATCHES_RCVD,T_DKIM_INVALID,UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Firmware peer entries are involved in internal firmware vdev structures. This was not accounted for and could lead firmware to crash due to asking it to do more than it could. Fixes: 039a0051ec1a ("ath10k: allocate fw resources for iface combinations") Signed-off-by: Michal Kazior --- drivers/net/wireless/ath/ath10k/mac.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/drivers/net/wireless/ath/ath10k/mac.c b/drivers/net/wireless/ath/ath10k/mac.c index 4f6dddac8e43..29ad1d3deb82 100644 --- a/drivers/net/wireless/ath/ath10k/mac.c +++ b/drivers/net/wireless/ath/ath10k/mac.c @@ -598,11 +598,19 @@ ath10k_mac_get_any_chandef_iter(struct ieee80211_hw *hw, static int ath10k_peer_create(struct ath10k *ar, u32 vdev_id, const u8 *addr, enum wmi_peer_type peer_type) { + struct ath10k_vif *arvif; + int num_peers = 0; int ret; lockdep_assert_held(&ar->conf_mutex); - if (ar->num_peers >= ar->max_num_peers) + num_peers = ar->num_peers; + + /* Each vdev consumes a peer entry as well */ + list_for_each_entry(arvif, &ar->arvifs, list) + num_peers++; + + if (num_peers >= ar->max_num_peers) return -ENOBUFS; ret = ath10k_wmi_peer_create(ar, vdev_id, addr, peer_type); @@ -4086,6 +4094,11 @@ static int ath10k_add_interface(struct ieee80211_hw *hw, sizeof(arvif->bitrate_mask.control[i].vht_mcs)); } + if (ar->num_peers >= ar->max_num_peers) { + ath10k_warn(ar, "refusing vdev creation due to insufficient peer entry resources in firmware\n"); + return -ENOBUFS; + } + if (ar->free_vdev_map == 0) { ath10k_warn(ar, "Free vdev map is empty, no more interfaces allowed.\n"); ret = -EBUSY;