From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.0 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,T_DKIMWL_WL_HIGH,URIBL_BLOCKED,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6258DC28CC2 for ; Thu, 30 May 2019 04:32:12 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 3B38A256C0 for ; Thu, 30 May 2019 04:32:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1559190732; bh=VGzhhKbe+lFSOO+k1naK0jo0kuQdMPAcQZFTCeTS41U=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=c35Pc74kNtVMFIHeyPfGFrhei3S9klrQqJZn7/laTWbRMBNhC+FB51QH1sngMqQ15 B2vOmZgPOBuLhsj7NbDviGMY5yBsd+cg6s+oz+s47/ubE0uLyA/B0IGnwWvY46Mo4a Bh9PSDsviospB8N5BY34B+YJ2RfW0cuD9hGdr17A= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728678AbfE3EcH (ORCPT ); Thu, 30 May 2019 00:32:07 -0400 Received: from mail.kernel.org ([198.145.29.99]:59668 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729547AbfE3DNl (ORCPT ); Wed, 29 May 2019 23:13:41 -0400 Received: from localhost (ip67-88-213-2.z213-88-67.customer.algx.net [67.88.213.2]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id E4D452456A; Thu, 30 May 2019 03:13:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1559186021; bh=VGzhhKbe+lFSOO+k1naK0jo0kuQdMPAcQZFTCeTS41U=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=hZBZOs9I0wX/cj5acvpHcYB6uo+qUwkoOxFc6qWZ9UoWevOXDQKXgqMvdOzuEk2e6 a46baoDRVKAEW0OvfclZdhXKEf+jEVYSjsguDmwyuiL2vwrLbkhRVQQ8sYrLYeQN53 zrwZgS6m239cLU3YXvrnixfF6WPIAPi5aXFz4TyQ= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Johannes Berg , Luca Coelho , Sasha Levin Subject: [PATCH 5.0 090/346] iwlwifi: pcie: dont crash on invalid RX interrupt Date: Wed, 29 May 2019 20:02:43 -0700 Message-Id: <20190530030545.725366167@linuxfoundation.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190530030540.363386121@linuxfoundation.org> References: <20190530030540.363386121@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org [ Upstream commit 30f24eabab8cd801064c5c37589d803cb4341929 ] If for some reason the device gives us an RX interrupt before we're ready for it, perhaps during device power-on with misconfigured IRQ causes mapping or so, we can crash trying to access the queues. Prevent that by checking that we actually have RXQs and that they were properly allocated. Signed-off-by: Johannes Berg Signed-off-by: Luca Coelho Signed-off-by: Sasha Levin --- drivers/net/wireless/intel/iwlwifi/pcie/rx.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/drivers/net/wireless/intel/iwlwifi/pcie/rx.c b/drivers/net/wireless/intel/iwlwifi/pcie/rx.c index c596c7b13504d..4354c0fedda78 100644 --- a/drivers/net/wireless/intel/iwlwifi/pcie/rx.c +++ b/drivers/net/wireless/intel/iwlwifi/pcie/rx.c @@ -1384,10 +1384,15 @@ static struct iwl_rx_mem_buffer *iwl_pcie_get_rxb(struct iwl_trans *trans, static void iwl_pcie_rx_handle(struct iwl_trans *trans, int queue) { struct iwl_trans_pcie *trans_pcie = IWL_TRANS_GET_PCIE_TRANS(trans); - struct iwl_rxq *rxq = &trans_pcie->rxq[queue]; + struct iwl_rxq *rxq; u32 r, i, count = 0; bool emergency = false; + if (WARN_ON_ONCE(!trans_pcie->rxq || !trans_pcie->rxq[queue].bd)) + return; + + rxq = &trans_pcie->rxq[queue]; + restart: spin_lock(&rxq->lock); /* uCode's read index (stored in shared DRAM) indicates the last Rx -- 2.20.1