Received: by 2002:a25:6193:0:0:0:0:0 with SMTP id v141csp234742ybb; Fri, 3 Apr 2020 01:32:25 -0700 (PDT) X-Google-Smtp-Source: APiQypIr5FsxZf5UjR5xvgajxclbr91uMA22Eos05TA9EBttBZMvRA8b/Jc/FI80BAyWT+1nLCxA X-Received: by 2002:a05:6808:12:: with SMTP id u18mr2266953oic.167.1585902745573; Fri, 03 Apr 2020 01:32:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1585902745; cv=none; d=google.com; s=arc-20160816; b=0JWHZB3hPMI14rkEymTZBCNmARGzsn6zNF/NVwCOuQXnRw8rl8UiBwX2m/Tcs6JOJm 23TktDKi49BGCe/uODJNpWFtK7yjThW58GEraOOeb/DToAQT5eGr7XcHi8wKzXp4lRoZ WDbwXCwqUrQlKdlWOf5S8iez9qaWXeZxl3ZIG4uE9vXlhv4Cun17BrXXMFZQWMGd2bsp 0Xo6wz/H0zCgCJUajiAZF8BQp8Bvd16e+JJOPoqcXenenF5HQ/bRlWrcSG7JUWhfEkuS uiHQy7sLdHfjC4aYaogVAnlQlqGfyNMJv017n+DlFDvtU++9pQ9R/kRyoDOWevZemx21 z41A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:subject:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:cc:to:from; bh=a2irNVwB8jIERVCx5FtlMNgQrqWZJ8u0FT5RLQQdLEo=; b=cf5ZPWs/Nnk0csxbGemdpME+yGaR6fQd+fwy9PqqppZ1Gqj4ht+Kj5rc9AfnLq1G+0 dJyj0uaoIubehrfZ8im/ZvX2pLMAikZszUWMRM3tZLCejVPB4RskqUq/igaElRrFjtf7 nSNSebhjSmZ7e74PqvW17F+vuGvyIbEihtvcKYz0Dh36wq1C0aZ6XvbahAuPq0RVJktw lp79K3GtO39CsDpRZpNlj1e0dSRqWu7oWltGmpUnVAPrT1Kwo61js6ouhFMe6zmGHqLd s1AHWKYcrvcbEOWSz+wxTS4Cf/ZyI8cI+SGK3kx2axwK4Psmtt7Junci3otFQdRuhSi7 QagA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-wireless-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-wireless-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id k20si3325140otb.168.2020.04.03.01.32.14; Fri, 03 Apr 2020 01:32:25 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-wireless-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-wireless-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-wireless-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2390547AbgDCIaJ (ORCPT + 99 others); Fri, 3 Apr 2020 04:30:09 -0400 Received: from paleale.coelho.fi ([176.9.41.70]:45456 "EHLO farmhouse.coelho.fi" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S2390435AbgDCIaI (ORCPT ); Fri, 3 Apr 2020 04:30:08 -0400 Received: from 91-156-6-193.elisa-laajakaista.fi ([91.156.6.193] helo=redipa.ger.corp.intel.com) by farmhouse.coelho.fi with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.93) (envelope-from ) id 1jKHiI-0008yu-IG; Fri, 03 Apr 2020 11:30:07 +0300 From: Luca Coelho To: kvalo@codeaurora.org Cc: linux-wireless@vger.kernel.org Date: Fri, 3 Apr 2020 11:29:51 +0300 Message-Id: X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200403082955.1126339-1-luca@coelho.fi> References: <20200403082955.1126339-1-luca@coelho.fi> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on farmhouse.coelho.fi X-Spam-Level: X-Spam-Status: No, score=-2.9 required=5.0 tests=ALL_TRUSTED,BAYES_00, TVD_RCVD_IP autolearn=ham autolearn_force=no version=3.4.4 Subject: [PATCH v5.7 4/8] iwlwifi: mvm: limit maximum queue appropriately Sender: linux-wireless-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org From: Johannes Berg Due to some hardware issues, queue 32 isn't usable on devices that have 32 queues (7000, 8000, 9000 families), which is correctly reflected in the configuration and TX queue initialization. However, the firmware API and queue allocation code assumes that there are 32 queues, and if something actually attempts to use #31 this leads to a NULL-pointer dereference since it's not allocated. Fix this by limiting to 31 in the IWL_MVM_DQA_MAX_DATA_QUEUE, and also add some code to catch this earlier in the future, if the configuration changes perhaps. Cc: stable@vger.kernel.org # v4.9+ Signed-off-by: Johannes Berg Signed-off-by: Luca Coelho --- drivers/net/wireless/intel/iwlwifi/fw/api/txq.h | 6 +++--- drivers/net/wireless/intel/iwlwifi/mvm/sta.c | 5 +++++ 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/drivers/net/wireless/intel/iwlwifi/fw/api/txq.h b/drivers/net/wireless/intel/iwlwifi/fw/api/txq.h index 73196cbc7fbe..75d958bab0e3 100644 --- a/drivers/net/wireless/intel/iwlwifi/fw/api/txq.h +++ b/drivers/net/wireless/intel/iwlwifi/fw/api/txq.h @@ -8,7 +8,7 @@ * Copyright(c) 2007 - 2014 Intel Corporation. All rights reserved. * Copyright(c) 2013 - 2015 Intel Mobile Communications GmbH * Copyright(c) 2016 - 2017 Intel Deutschland GmbH - * Copyright(c) 2019 Intel Corporation + * Copyright(c) 2019 - 2020 Intel Corporation * * This program is free software; you can redistribute it and/or modify * it under the terms of version 2 of the GNU General Public License as @@ -31,7 +31,7 @@ * Copyright(c) 2005 - 2014 Intel Corporation. All rights reserved. * Copyright(c) 2013 - 2015 Intel Mobile Communications GmbH * Copyright(c) 2016 - 2017 Intel Deutschland GmbH - * Copyright(c) 2019 Intel Corporation + * Copyright(c) 2019 - 2020 Intel Corporation * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -99,7 +99,7 @@ enum iwl_mvm_dqa_txq { IWL_MVM_DQA_MAX_MGMT_QUEUE = 8, IWL_MVM_DQA_AP_PROBE_RESP_QUEUE = 9, IWL_MVM_DQA_MIN_DATA_QUEUE = 10, - IWL_MVM_DQA_MAX_DATA_QUEUE = 31, + IWL_MVM_DQA_MAX_DATA_QUEUE = 30, }; enum iwl_mvm_tx_fifo { diff --git a/drivers/net/wireless/intel/iwlwifi/mvm/sta.c b/drivers/net/wireless/intel/iwlwifi/mvm/sta.c index 64ef3f3ba23b..251d6fbb1da5 100644 --- a/drivers/net/wireless/intel/iwlwifi/mvm/sta.c +++ b/drivers/net/wireless/intel/iwlwifi/mvm/sta.c @@ -722,6 +722,11 @@ static int iwl_mvm_find_free_queue(struct iwl_mvm *mvm, u8 sta_id, lockdep_assert_held(&mvm->mutex); + if (WARN(maxq >= mvm->trans->trans_cfg->base_params->num_of_queues, + "max queue %d >= num_of_queues (%d)", maxq, + mvm->trans->trans_cfg->base_params->num_of_queues)) + maxq = mvm->trans->trans_cfg->base_params->num_of_queues - 1; + /* This should not be hit with new TX path */ if (WARN_ON(iwl_mvm_has_new_tx_api(mvm))) return -ENOSPC; -- 2.25.1