Received: by 2002:ac0:bc90:0:0:0:0:0 with SMTP id a16csp5584406img; Wed, 27 Mar 2019 11:09:20 -0700 (PDT) X-Google-Smtp-Source: APXvYqxOZet/mbFAKc3N5veFH0JKCm2U7yn17kHwly+2z5Sv45OUwoVVxgRl9qLVfcICILzQgqox X-Received: by 2002:a17:902:a5c3:: with SMTP id t3mr38686039plq.293.1553710160491; Wed, 27 Mar 2019 11:09:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1553710160; cv=none; d=google.com; s=arc-20160816; b=YZF/ejgqXxnq/W7itdGAmrlgcpcS4hx0bm/Mo+ysW/x3qhmwcaXZSgvRTKn/O1G2fV 5+Zrzy5cTGlAEie8mISM/lvlDcb7/Ok7bJf0eVyg9Kjd599HVIdBEolBwcaA5SJWNf/0 0ZWkzdbp9j/UmzQmD+FlhQQxh6/PANFDbMKEwWSgX5Vcmv4XpjnsrT6RQ6FaKC5X4JH9 ihmGjGTH0KMrdHRsaOeeBlJStVP7JJyIwDt0xoMx68k74ecYtitWH43rSw0YtChRTtE0 LscFQoYXS6596vAkR348Q7uewfwmvu3C5/miH/87RQAsoUyi+cUqdOUa6AiUlHX7aQRW 7BEw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=RuO9AqcmEy4PQOT13y7obpkfpNyvtY1rOd7+hPA1RAQ=; b=zf03beOFhC6ypv6q0LFG8mOSfMcs80VpuOl2B4KX3mP35BmCJEvJTDT45OsGaq9ZHz bk2VbmVwJtBiOL0Eq5pdaZDiWUuUOdFRvc/IBrGBad3D7YB3K4KiiMY10brUFK5053gm 1NqB7yvhc2PBWdufaNE95st4l66XHyWmtptUxOaB+QQcMm+Zf0s/sHK0EqflkGWrQEM+ pd0UxqnWJIdQu1L+gua2iSre3Pa6LP/5bAlgOJJQTerNJw1V5LLD3IYy/JbhePfG6KsS YeCN/QqS9r9XY01ARk+PMNQq8hmojD2+JRSvY04MVpMdO51N0eZgMqTu3co39sCsKhHf Fvqg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=gFUzrEP3; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id d2si4064487pgq.129.2019.03.27.11.09.05; Wed, 27 Mar 2019 11:09:20 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=gFUzrEP3; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1733309AbfC0SHw (ORCPT + 99 others); Wed, 27 Mar 2019 14:07:52 -0400 Received: from mail.kernel.org ([198.145.29.99]:49704 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388247AbfC0SHt (ORCPT ); Wed, 27 Mar 2019 14:07:49 -0400 Received: from sasha-vm.mshome.net (c-73-47-72-35.hsd1.nh.comcast.net [73.47.72.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id A308A2063F; Wed, 27 Mar 2019 18:07:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1553710068; bh=KmERyaP2SScHkgC+FfJ/EX4B148TZzpTex/i/vYfU+o=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=gFUzrEP3MZx8/WaK27N2zs46MDMbLggk3yrXRwnqp3icrTOCjFdbmEa7rFj8BR7Ub 98eODEraGHUZ9kMxae5wtM52lAvU5njqX/uZ4/a9vfIWNBMLR6WxF9gIA8PyQC3uNL NIVGVsJk5fGUIRpFMW+aQ7kjJ8rinnqMTc+/eWps= From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Johannes Berg , Luca Coelho , Sasha Levin , linux-wireless@vger.kernel.org, netdev@vger.kernel.org Subject: [PATCH AUTOSEL 5.0 182/262] iwlwifi: mvm: fix RFH config command with >=10 CPUs Date: Wed, 27 Mar 2019 14:00:37 -0400 Message-Id: <20190327180158.10245-182-sashal@kernel.org> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20190327180158.10245-1-sashal@kernel.org> References: <20190327180158.10245-1-sashal@kernel.org> MIME-Version: 1.0 X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Johannes Berg [ Upstream commit dbf592f3d14fb7d532cb7c820b1065cf33e02aaa ] If we have >=10 (logical) CPUs, our command size exceeds the internal buffer size and the command fails; fix that by using IWL_HCMD_DFL_NOCOPY for the command that's allocated anyway. While at it, also fix the leak of cmd, and use struct_size() to calculate its size. Signed-off-by: Johannes Berg Fixes: 8edbfaa19835 ("iwlwifi: mvm: configure multi RX queue") Signed-off-by: Luca Coelho Signed-off-by: Sasha Levin --- drivers/net/wireless/intel/iwlwifi/mvm/fw.c | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/drivers/net/wireless/intel/iwlwifi/mvm/fw.c b/drivers/net/wireless/intel/iwlwifi/mvm/fw.c index 0d6c313b6669..19ec55cef802 100644 --- a/drivers/net/wireless/intel/iwlwifi/mvm/fw.c +++ b/drivers/net/wireless/intel/iwlwifi/mvm/fw.c @@ -127,13 +127,17 @@ static int iwl_send_rss_cfg_cmd(struct iwl_mvm *mvm) static int iwl_configure_rxq(struct iwl_mvm *mvm) { - int i, num_queues, size; + int i, num_queues, size, ret; struct iwl_rfh_queue_config *cmd; + struct iwl_host_cmd hcmd = { + .id = WIDE_ID(DATA_PATH_GROUP, RFH_QUEUE_CONFIG_CMD), + .dataflags[0] = IWL_HCMD_DFL_NOCOPY, + }; /* Do not configure default queue, it is configured via context info */ num_queues = mvm->trans->num_rx_queues - 1; - size = sizeof(*cmd) + num_queues * sizeof(struct iwl_rfh_queue_data); + size = struct_size(cmd, data, num_queues); cmd = kzalloc(size, GFP_KERNEL); if (!cmd) @@ -154,10 +158,14 @@ static int iwl_configure_rxq(struct iwl_mvm *mvm) cmd->data[i].fr_bd_wid = cpu_to_le32(data.fr_bd_wid); } - return iwl_mvm_send_cmd_pdu(mvm, - WIDE_ID(DATA_PATH_GROUP, - RFH_QUEUE_CONFIG_CMD), - 0, size, cmd); + hcmd.data[0] = cmd; + hcmd.len[0] = size; + + ret = iwl_mvm_send_cmd(mvm, &hcmd); + + kfree(cmd); + + return ret; } static int iwl_mvm_send_dqa_cmd(struct iwl_mvm *mvm) -- 2.19.1