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=ham 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 B4D11C28CC0 for ; Thu, 30 May 2019 03:29:40 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 8ACF924AB3 for ; Thu, 30 May 2019 03:29:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1559186980; bh=xHVzDq91aH0SJhrqyRTORQomLvIyxj+MOPYxDC+DYK4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=Bm5USM6JdO5YSz2xsmyXhgqJgkugy3GfyLBwzDmXD75El0U0U2wC70katibYlmNC/ a6y7oxrLufnp8jAKNw0zxo+s3G/vm3FjXr0qcLWbWnJedhE6zz1ik5hCnLqI4eRcOG 7Eb3BU40cZyWzGBtF6JnCCI98phghu5ZYvYZKGto= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388426AbfE3D3i (ORCPT ); Wed, 29 May 2019 23:29:38 -0400 Received: from mail.kernel.org ([198.145.29.99]:60008 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730575AbfE3DUr (ORCPT ); Wed, 29 May 2019 23:20:47 -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 21D8F2496F; Thu, 30 May 2019 03:20:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1559186447; bh=xHVzDq91aH0SJhrqyRTORQomLvIyxj+MOPYxDC+DYK4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=aAX7HdddUkmF56IjZtnmHpDnyuJ5b5ie8gPmEXg10EWvtVWspm3uAKK0k8h/0o5Ra O5otIA/3O3rD0uD1vpBlW3B86ekuE9AXuy/er17XB4PcpeETMXMHP5zGunKt91cIg0 9FfyRb1nFm5l+pHo3BIt3cu9Q7y6FLYznocwrWv0= 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 4.9 037/128] iwlwifi: pcie: dont crash on invalid RX interrupt Date: Wed, 29 May 2019 20:06:09 -0700 Message-Id: <20190530030440.829423723@linuxfoundation.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190530030432.977908967@linuxfoundation.org> References: <20190530030432.977908967@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@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 c21f8bd32d08f..25f2a0aceaa21 100644 --- a/drivers/net/wireless/intel/iwlwifi/pcie/rx.c +++ b/drivers/net/wireless/intel/iwlwifi/pcie/rx.c @@ -1225,10 +1225,15 @@ static void iwl_pcie_rx_handle_rb(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