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=-8.8 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,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 9E942C48BE1 for ; Thu, 20 Jun 2019 18:26:53 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 7DBB2206BF for ; Thu, 20 Jun 2019 18:26:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1561055213; bh=DNCHDIg7+LpQuvS1H0EHeoebf7KBvvFcuRF/NGxy6To=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=pkrHWlNQBu7mBOXBFelO8wcjgtu34U0G4TXV+KM23/tu1M6ZNbZ9HF0A26E5pu0Va McS9PDGY3VTBLo2ZQl53bRS994cPwKriv6AOE2FPKhfF87ouvEgduolCG/mirCutY5 h+MfJ4Vh0KSqs81hzP6ck3Ytkr93DtDN1PfU5m+s= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727222AbfFTSFf (ORCPT ); Thu, 20 Jun 2019 14:05:35 -0400 Received: from mail.kernel.org ([198.145.29.99]:59036 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727752AbfFTSFd (ORCPT ); Thu, 20 Jun 2019 14:05:33 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (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 E2112204FD; Thu, 20 Jun 2019 18:05:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1561053932; bh=DNCHDIg7+LpQuvS1H0EHeoebf7KBvvFcuRF/NGxy6To=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=dcGgOB08wvBEpkGTlfTnxgtZoAhtWvF93WxWgzcXGjU7fszXvIHahSSqTVH23D2bV KyHx2egGZK58hBIeLslzZz7Z153H/rKskNjhqlk7R1R1U3Pf3dhVY/YKy+MOtVvYvw oM8eP+3g2ZTZFfeSPzTvauyl9xDwZ9kSZpxAfm94= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Kangjie Lu , Lorenzo Pieralisi , Steven Price , Mukesh Ojha , Sasha Levin Subject: [PATCH 4.9 048/117] PCI: xilinx: Check for __get_free_pages() failure Date: Thu, 20 Jun 2019 19:56:22 +0200 Message-Id: <20190620174354.826792039@linuxfoundation.org> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190620174351.964339809@linuxfoundation.org> References: <20190620174351.964339809@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 699ca30162686bf305cdf94861be02eb0cf9bda2 ] If __get_free_pages() fails, return -ENOMEM to avoid a NULL pointer dereference. Signed-off-by: Kangjie Lu Signed-off-by: Lorenzo Pieralisi Reviewed-by: Steven Price Reviewed-by: Mukesh Ojha Signed-off-by: Sasha Levin --- drivers/pci/host/pcie-xilinx.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/drivers/pci/host/pcie-xilinx.c b/drivers/pci/host/pcie-xilinx.c index 61332f4d51c3..c3964fca57b0 100644 --- a/drivers/pci/host/pcie-xilinx.c +++ b/drivers/pci/host/pcie-xilinx.c @@ -337,14 +337,19 @@ static const struct irq_domain_ops msi_domain_ops = { * xilinx_pcie_enable_msi - Enable MSI support * @port: PCIe port information */ -static void xilinx_pcie_enable_msi(struct xilinx_pcie_port *port) +static int xilinx_pcie_enable_msi(struct xilinx_pcie_port *port) { phys_addr_t msg_addr; port->msi_pages = __get_free_pages(GFP_KERNEL, 0); + if (!port->msi_pages) + return -ENOMEM; + msg_addr = virt_to_phys((void *)port->msi_pages); pcie_write(port, 0x0, XILINX_PCIE_REG_MSIBASE1); pcie_write(port, msg_addr, XILINX_PCIE_REG_MSIBASE2); + + return 0; } /* INTx Functions */ @@ -516,6 +521,7 @@ static int xilinx_pcie_init_irq_domain(struct xilinx_pcie_port *port) struct device *dev = port->dev; struct device_node *node = dev->of_node; struct device_node *pcie_intc_node; + int ret; /* Setup INTx */ pcie_intc_node = of_get_next_child(node, NULL); @@ -544,7 +550,9 @@ static int xilinx_pcie_init_irq_domain(struct xilinx_pcie_port *port) return -ENODEV; } - xilinx_pcie_enable_msi(port); + ret = xilinx_pcie_enable_msi(port); + if (ret) + return ret; } return 0; -- 2.20.1