Received: by 2002:ac0:bc90:0:0:0:0:0 with SMTP id a16csp832154img; Fri, 22 Mar 2019 09:28:00 -0700 (PDT) X-Google-Smtp-Source: APXvYqxCmqQI+kgAwUkIPruuugSEKIqXNBWc1Z/5IW7blUjh1tn9hfVkY3QUdDJtasZ9O7lrsS50 X-Received: by 2002:a65:4341:: with SMTP id k1mr9686323pgq.175.1553272080302; Fri, 22 Mar 2019 09:28:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1553272080; cv=none; d=google.com; s=arc-20160816; b=I2ax+S7Z4E484StkFbuDJkG7qNAeiNhrL13sZleZQ3U5x2ssx1zaSem6EFovyo0ZVc gFXFU1IR0M8U6cRojQmjD5MddReP+6tkzxJpWizagWCaopRP5Gje6V9FkalJpRQOGCDn xgBjeesvQthhmQBSCArXnOaxu2MDZbIk5ciV9XAkp6ZC3RzOlbMhJB52PB/r5PjpbuTa tBipJfBQHskV2EYJ2l7bzoB+t2+JON++/NI3eZLVVWmf4BPnaYv+8oJ0SajU9sjMycvO Zvidt+M8+iRIa8o+yMnPtH4ItOQhZHyLkb/HldiAdfBNLO2K0ESpe9+3Oq78KIJrPsb/ k4nA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject; bh=ybiFuojEbVjBZ7599sSNaBQVK/8yTE1XEAlhrew5UvA=; b=uECT85oec0SJVemApJNYJmuQvC1Lk5ssbLe+AwE2yDQwJtm4MFLXa2IdneUkkgG1kQ +cOQ/rvkhb8SsFMZ8fqNd2E3HPeSdOVO0R6pGZ6dNDKLKeq9ALhh7VlZmUCZSwIr/vPu 3vV9/p+vIaIMfF7qLBzhAVi8bdAXHhVmp5i7eyYcCfu3A+DY7tC8g+zmAEBjYJ9z/PmX 0AKYANwNGXacfBTqwLjkfANdZRzjGi1FgLrEelCgTni9ouWpUkskY62aV4qvSJQnXtzg fSGl+fqX718BXBClzQmyKasIFjo+B5wStY4wp4kG+qnZi6JRTfiRhKP+x65gTEZKoHfw beSw== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id l66si7004158pgl.474.2019.03.22.09.27.45; Fri, 22 Mar 2019 09:28: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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727028AbfCVQ0c (ORCPT + 99 others); Fri, 22 Mar 2019 12:26:32 -0400 Received: from usa-sjc-mx-foss1.foss.arm.com ([217.140.101.70]:49028 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726034AbfCVQ0c (ORCPT ); Fri, 22 Mar 2019 12:26:32 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 00D5EA78; Fri, 22 Mar 2019 09:26:32 -0700 (PDT) Received: from [10.1.196.69] (e112269-lin.cambridge.arm.com [10.1.196.69]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 9A1603F59C; Fri, 22 Mar 2019 09:26:30 -0700 (PDT) Subject: Re: [PATCH] pci: pcie-xilinx: fix a missing-check bug for __get_free_pages To: Kangjie Lu Cc: Lorenzo Pieralisi , linux-pci@vger.kernel.org, Michal Simek , linux-kernel@vger.kernel.org, pakki001@umn.edu, Bjorn Helgaas , linux-arm-kernel@lists.infradead.org References: <20190314055851.6884-1-kjlu@umn.edu> From: Steven Price Message-ID: Date: Fri, 22 Mar 2019 16:26:29 +0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.5.1 MIME-Version: 1.0 In-Reply-To: <20190314055851.6884-1-kjlu@umn.edu> Content-Type: text/plain; charset=utf-8 Content-Language: en-GB Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 14/03/2019 05:58, Kangjie Lu wrote: > In case __get_free_pages fail, the fix returns to avoid NULL > pointer dereference. > > Signed-off-by: Kangjie Lu > --- > drivers/pci/controller/pcie-xilinx.c | 3 +++ > 1 file changed, 3 insertions(+) > > diff --git a/drivers/pci/controller/pcie-xilinx.c b/drivers/pci/controller/pcie-xilinx.c > index 9bd1a35cd5d8..b7083e995c45 100644 > --- a/drivers/pci/controller/pcie-xilinx.c > +++ b/drivers/pci/controller/pcie-xilinx.c > @@ -341,6 +341,9 @@ static void 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; Shouldn't the function return an error code for the calling function to see? With this change the caller (xilinx_pcie_init_irq_domain) will think that MSIs were enabled, but actually they weren't. Steve > + > 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); >