Received: by 2002:a25:1985:0:0:0:0:0 with SMTP id 127csp256319ybz; Fri, 17 Apr 2020 00:11:56 -0700 (PDT) X-Google-Smtp-Source: APiQypInUOoq+uLFFdk+lCDq3/LfVIDP9T/SmfcivgwpGh08aXu3TUWEZC5xuEtS6GDmnKQYlDHN X-Received: by 2002:a05:6402:17e3:: with SMTP id t3mr1660829edy.203.1587107516263; Fri, 17 Apr 2020 00:11:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1587107516; cv=none; d=google.com; s=arc-20160816; b=qUJ15QjrKNZAUI7JkMBYBvX4LJM1ZkU2pMPYDAW5DWjn9eVI+FdXnC26u4e2oo8kit py5eivasoMMgjL5R8NHxJDtz5QBpT45Ki0+Zm0kYKtEv1zK2pffviUfodZvg12l3i4kZ Hkbne7uXI3xA8hnuqKPtaE3HEGaETXr+gr6YEa7tCHvwlEy+48NfXAimarvqn7UBqIow qW2tCyvGislg1e+DbxzJ46uyZSlRnLllyoBg0zni9MO5Ax30MrMCmb7joBRD64nzzwFZ hoDDQN5RL9lzJQanbhW4mWo34vIN79byGfk7mhjcAw/4SzClHlIw+bVTu4sP+B/Zb7fg s2Rg== 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=xtvEMAVQJvavTfOQcL8XQzLxPb73x4D8/MQF5+YXX90=; b=m8nELgUymzBnCUH6mFXhrF5ax8cbvBe9EUKJnxcZeN9drGopMMoCnbAb3T+s9NSVkW yjk+i8a2cKs+iS8MSwGgoGbdVokIN3vYIdlzG1F83O4qCCeXsAiSdg06OS7RF1Oe1lH6 LMkfm4zlABPCso261TAvcuL2SRimbHBEnL5h+FEL6WzJ8clD1U4H24f7RvikGG7Wl9YL dqOyu5IFIL0s8QnWF4Gqjqb6V1++1wlImdDveVKKd+Fv02VGizHjXg9cWuGeEtOzxRDB +qv+F4oU1Z23tH0cy4NjdWRlDgM6rFVPsaS1wMwsFqTSFlktY4j5dgT7KP76hkIgPP6g ZXww== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-wireless-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id hk16si13898342ejb.263.2020.04.17.00.11.32; Fri, 17 Apr 2020 00:11:56 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-wireless-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728753AbgDQHI2 (ORCPT + 99 others); Fri, 17 Apr 2020 03:08:28 -0400 Received: from paleale.coelho.fi ([176.9.41.70]:56388 "EHLO farmhouse.coelho.fi" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1728470AbgDQHI1 (ORCPT ); Fri, 17 Apr 2020 03:08:27 -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 1jPL6v-000KNJ-ND; Fri, 17 Apr 2020 10:08:26 +0300 From: Luca Coelho To: kvalo@codeaurora.org Cc: linux-wireless@vger.kernel.org Date: Fri, 17 Apr 2020 10:08:12 +0300 Message-Id: X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200417070814.2044774-1-luca@coelho.fi> References: <20200417070814.2044774-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 v2 v5.7 4/6] 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 31 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