From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from [140.186.70.92] (port=40073 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OuoSS-0000N1-23 for qemu-devel@nongnu.org; Sun, 12 Sep 2010 11:27:09 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1OuoSQ-0006Zz-Qb for qemu-devel@nongnu.org; Sun, 12 Sep 2010 11:27:07 -0400 Received: from mx1.redhat.com ([209.132.183.28]:42016) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1OuoSQ-0006Zr-KH for qemu-devel@nongnu.org; Sun, 12 Sep 2010 11:27:06 -0400 Date: Sun, 12 Sep 2010 17:21:06 +0200 From: "Michael S. Tsirkin" Message-ID: <20100912152106.GA5092@redhat.com> References: <923c10aea223d40b50f1a641becf08b7a647f541.1284000417.git.yamahata@valinux.co.jp> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <923c10aea223d40b50f1a641becf08b7a647f541.1284000417.git.yamahata@valinux.co.jp> Subject: [Qemu-devel] Re: [PATCH 2/3] pci: don't ignore invalid parameter for pci_register_bar(). List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Isaku Yamahata Cc: qemu-devel@nongnu.org On Thu, Sep 09, 2010 at 11:48:56AM +0900, Isaku Yamahata wrote: > Abort when invalid value for region_num is passed to pci_register_bar. > That is caller's bug. Abort instead of silently ignoring invalid value. > > Signed-off-by: Isaku Yamahata > --- > hw/pci.c | 5 ++--- > 1 files changed, 2 insertions(+), 3 deletions(-) Applied. > diff --git a/hw/pci.c b/hw/pci.c > index 8d6b299..31eba9a 100644 > --- a/hw/pci.c > +++ b/hw/pci.c > @@ -765,9 +765,8 @@ void pci_register_bar(PCIDevice *pci_dev, int region_num, > uint32_t addr; > uint64_t wmask; > > - if ((unsigned int)region_num >= PCI_NUM_REGIONS) > - return; > - > + assert(region_num >= 0); > + assert(region_num < PCI_NUM_REGIONS); > if (size & (size-1)) { > fprintf(stderr, "ERROR: PCI region size must be pow2 " > "type=0x%x, size=0x%"FMT_PCIBUS"\n", type, size); > -- > 1.7.1.1