From: Isaku Yamahata Subject: Re: [Qemu-devel] [PATCH 3/3] Check pci slot number in parse_pci_devfn Date: Tue, 24 Aug 2010 20:35:21 +0900 Message-ID: <20100824113521.GA7201@valinux.co.jp> References: <20100824063307.GA10815@kt> <20100824064927.GB11495@kt> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Cc: kvm@vger.kernel.org, qemu-devel@nongnu.org, "Michael S\. Tsirkin" To: Ken CC Return-path: Received: from mail.valinux.co.jp ([210.128.90.3]:40129 "EHLO mail.valinux.co.jp" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751351Ab0HXLYy (ORCPT ); Tue, 24 Aug 2010 07:24:54 -0400 Content-Disposition: inline In-Reply-To: <20100824064927.GB11495@kt> Sender: kvm-owner@vger.kernel.org List-ID: Add Cc: mst@redhat.com. MAX_PCI_SLOTS should be in pci.h instead of qdev.h? And the name should be start with PCI_ prefix for consistency? Except that, the patches look okay. thanks, On Tue, Aug 24, 2010 at 02:49:27PM +0800, Ken CC wrote: > Define MAX_PCI_SLOTS as 0x1f, if pci addr provided from command line > is bigger than 0x1f, return error -EINVAL. > > 0x1f << 3 | 7 == 255 (PCIBUS_MAX_DEVICES - 1) > > Signed-off-by: Ken CC > --- > hw/qdev-properties.c | 2 ++ > hw/qdev.h | 3 +++ > 2 files changed, 5 insertions(+), 0 deletions(-) > > diff --git a/hw/qdev-properties.c b/hw/qdev-properties.c > index 9219cd7..96d814c 100644 > --- a/hw/qdev-properties.c > +++ b/hw/qdev-properties.c > @@ -514,6 +514,8 @@ static int parse_pci_devfn(DeviceState *dev, Property *prop, const char *str) > return -EINVAL; > } > } > + if (slot > MAX_PCI_SLOTS) > + return -EINVAL; > if (str[n] != '\0') > return -EINVAL; > if (fn > 7) > diff --git a/hw/qdev.h b/hw/qdev.h > index 678f8b7..fcfe52e 100644 > --- a/hw/qdev.h > +++ b/hw/qdev.h > @@ -7,6 +7,9 @@ > #include "qemu-char.h" > #include "qemu-option.h" > > + > +#define MAX_PCI_SLOTS 0x1f > + > typedef struct Property Property; > > typedef struct PropertyInfo PropertyInfo; > > -- yamahata