Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932757AbcDNPxd (ORCPT ); Thu, 14 Apr 2016 11:53:33 -0400 Received: from smtp.codeaurora.org ([198.145.29.96]:56701 "EHLO smtp.codeaurora.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932243AbcDNPxc (ORCPT ); Thu, 14 Apr 2016 11:53:32 -0400 Subject: Re: [PATCH v2 4/4] ACPI: PCI: Add generic PCI host controller To: Jayachandran C , Bjorn Helgaas , Tomasz Nowicki , rafael@kernel.org References: <1460414707-19153-1-git-send-email-jchandra@broadcom.com> <1460414707-19153-5-git-send-email-jchandra@broadcom.com> Cc: Arnd Bergmann , Will Deacon , Catalin Marinas , Hanjun Guo , Lorenzo Pieralisi , jiang.liu@linux.intel.com, Stefano Stabellini , robert.richter@caviumnetworks.com, Marcin Wojtas , Liviu.Dudau@arm.com, David Daney , wangyijing@huawei.com, Suravee.Suthikulpanit@amd.com, msalter@redhat.com, linux-pci@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-acpi@vger.kernel.org, linux-kernel@vger.kernel.org, linaro-acpi@lists.linaro.org, Jon Masters From: Sinan Kaya Message-ID: <570FBCF6.50407@codeaurora.org> Date: Thu, 14 Apr 2016 11:53:26 -0400 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:38.0) Gecko/20100101 Thunderbird/38.7.2 MIME-Version: 1.0 In-Reply-To: <1460414707-19153-5-git-send-email-jchandra@broadcom.com> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 895 Lines: 27 On 4/11/2016 6:45 PM, Jayachandran C wrote: > +/* find the entry in cfgarr which contains range bus_start..bus_end */ > +static int mcfg_lookup(u16 seg, u8 bus_start, u8 bus_end) > +{ > + struct pci_config_window *cfg; > + int i; > + > + if (!cfgarr) > + return -ENOENT; > + > + for (i = 0; cfgarr[i]; i++) { > + cfg = cfgarr[i]; > + I see that you are allocating an array of cfgarr to keep the MCFG table entries. The above way of checking the number of entries is not correct. You should keep track of the number of entries you found out globally instead of relying an element being NULL or not. If you exceed the array size, you may or may not be lucky to find another entry in memory. -- Sinan Kaya Qualcomm Technologies, Inc. on behalf of Qualcomm Innovation Center, Inc. Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a Linux Foundation Collaborative Project