Received: by 2002:ac0:bc90:0:0:0:0:0 with SMTP id a16csp3648229img; Mon, 25 Mar 2019 14:52:00 -0700 (PDT) X-Google-Smtp-Source: APXvYqwxD7jR6+Qvv3KhvblMBwKc7bfbC9ZslyjYW/5doDYvMnc1uS824mNJ/rUpz1hDpuUXoJkc X-Received: by 2002:a63:cd06:: with SMTP id i6mr25917610pgg.267.1553550720575; Mon, 25 Mar 2019 14:52:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1553550720; cv=none; d=google.com; s=arc-20160816; b=Jsejos8pb5jSwNmvnnLAvW7CGzjlB9TdX20av1dIPoACT5YNQgV3YDnzE8N5p5s59f iLgprhUIUxUu81cYs0Y5NlEigliscwlBm2B5aNGdKdbQR8Urs/kd1rkhdvg7oxtKixtT 65E3i7+Cd0f/nyEJVy1tyFEk2NIIaTwPp4scEs85a7cbvkw7SOOcKz5OobkmnT64Rjxo +elE9UggeAjTA4sX2+Z51b77KwAbhK2n03ysDz+xgm6c43cnQ/WFg2k3VQbaSgKEauME LUVf7KIWN2agBjB4g4b6hPcMaLNJNVfUoxr5yy9bLHnbT9KKlbEzGdwjmhdakk7/x2zG FJbQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=ez1cQhu1XjGHM8+mfJmmB0HL5exK85IEVRIVzVdd6Kc=; b=mBCtF4sjNyBXrJ92AP9ja0nVZ425sxngJEBQXf3OsJsQQEGa8e2lDSay4rgCbVdeBL W/v4E9fuFswPIrzLqDtljVNgG/HIIQBsgwvn7/wY9lVcnSQLpCTMhhQqM3vZvcajZjzX 3H1lKGqZ7MFeqY30y5tLTIvGnVBsvg3jgLuifLDbD5BjRghGS85piqK/5vzleuC861kK 1opDoxhyV4b3uiXnFpk8HVhcYi2BsCfbaE4Md/M+TH1WbSOJLgY21C+gXuwmXdlDXibp lm9K27fPm+ZWXA/2yAjDNKdcT1xylNZ8yUjd6UuVHgKKzy5B4nJ/ZoybVVKqUj8cbD2G QozQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=a4mXjQEC; 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 o16si15194135pgc.327.2019.03.25.14.51.45; Mon, 25 Mar 2019 14:52:00 -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=a4mXjQEC; 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 S1730180AbfCYVvK (ORCPT + 99 others); Mon, 25 Mar 2019 17:51:10 -0400 Received: from mail.kernel.org ([198.145.29.99]:37764 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729414AbfCYVvJ (ORCPT ); Mon, 25 Mar 2019 17:51:09 -0400 Received: from localhost (unknown [69.71.4.100]) (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 F0CF7206DF; Mon, 25 Mar 2019 21:51:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1553550668; bh=Iy1CDnFErlvFInVMLBtWRRhdbBwy2pb0dVURBJT0vZY=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=a4mXjQEC7aYK2z3HNc7+OcJpARrfJbYR3Ptqmi6SS8tvHAm0epjVHoLFtQgS4l4DT qtRP9DgL+IFuH4PWEJECuIuK8p8TFFnTGi9hSi+I1fiC7ACQdKdPz0vpV6fXqmVvHi ZeED8MfCcIduYMTmaAl+o/UC7LyyFwU18TQnaz4s= Date: Mon, 25 Mar 2019 16:51:06 -0500 From: Bjorn Helgaas To: Kangjie Lu Cc: Lorenzo Pieralisi , linux-pci@vger.kernel.org, Michal Simek , linux-kernel@vger.kernel.org, pakki001@umn.edu, linux-arm-kernel@lists.infradead.org Subject: Re: [PATCH v2] pci: pcie-xilinx: fix a missing-check bug for __get_free_pages Message-ID: <20190325215105.GB24180@google.com> References: <20190325213113.24705-1-kjlu@umn.edu> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190325213113.24705-1-kjlu@umn.edu> User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Kangjie, Thanks for the patch! Please update the subject line like this: PCI: xilinx: Check for __get_free_pages() failure You can always get a good idea of the style for subject lines by doing something like this: git log --oneline --follow drivers/pci/controller/pcie-xilinx.c On Mon, Mar 25, 2019 at 04:31:13PM -0500, Kangjie Lu wrote: > In case __get_free_pages fail, the fix returns -ENOMEMto avoid > NULL pointer dereference. s/In case/If/ s/__get_free_pages/__get_free_pages()/ s/fail/fails/ s/the fix returns/return/ s/-ENOMEMto/-ENOMEM to/ > Signed-off-by: Kangjie Lu > Reviewed-by: Steven Price I didn't see Steven's reviewed-by on the mailing list. I did see his *review*, but his "Reviewed-by: Steven Price " implies that he reviewed it *and* believes it to ready for merging (see Documentation/process/submitting-patches.rst for all the details). So we should only add the Reviewed-by tag after Steven himself posts it. > --- > v2: caller is redefined to accept the error code, as suggested by > Steven Price > --- > 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 (unlikely(!port->msi_pages)) > + return -ENOMEM; No need to use "unlikely()" here. It *is* unlikely that __get_free_pages() will fail, but the annotation clutters the code a bit, so I prefer to avoid it except for performance paths. This should probably be documented somewhere in Documentation/process/, but regrettably, it isn't (yet). > 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; > -- > 2.17.1 > > > _______________________________________________ > linux-arm-kernel mailing list > linux-arm-kernel@lists.infradead.org > http://lists.infradead.org/mailman/listinfo/linux-arm-kernel