[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <377aa504-7bfa-4e8d-5db7-fce01c931e28@arm.com>
Date: Tue, 26 Mar 2019 11:40:51 +0000
From: Steven Price <steven.price@....com>
To: Kangjie Lu <kjlu@....edu>
Cc: Lorenzo Pieralisi <lorenzo.pieralisi@....com>,
linux-pci@...r.kernel.org, Michal Simek <michal.simek@...inx.com>,
linux-kernel@...r.kernel.org, pakki001@....edu,
Bjorn Helgaas <bhelgaas@...gle.com>,
linux-arm-kernel@...ts.infradead.org
Subject: Re: [PATCH v3] PCI: xilinx: Check for __get_free_pages() failure
On 25/03/2019 22:19, Kangjie Lu wrote:
> If __get_free_pages() fails, the patch returns -ENOMEM to avoid
As Bjorn suggested s/the patch returns/return/ would suffice and is
slightly easier to read. But I'm happy either way.
> NULL pointer dereference.
>
> Signed-off-by: Kangjie Lu <kjlu@....edu>
Reviewed-by: Steven Price <steven.price@....com>
> ---
> v3: remove "unlikely", as suggested by Bjorn Helgaas.
> v2: caller is redefined to accept the error code, as suggested by
> Steven Price <steven.price@....com>
> ---
> drivers/pci/controller/pcie-xilinx.c | 12 ++++++++++--
> 1 file changed, 10 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/pci/controller/pcie-xilinx.c b/drivers/pci/controller/pcie-xilinx.c
> index 9bd1a35cd5d8..abc214e94f7c 100644
> --- a/drivers/pci/controller/pcie-xilinx.c
> +++ b/drivers/pci/controller/pcie-xilinx.c
> @@ -336,14 +336,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 */
> @@ -498,6 +503,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);
> @@ -526,7 +532,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;
>
Powered by blists - more mailing lists