diff mbox

[2/3] pc-dimm: check if the value of node property

Message ID 798e3da98da2d7e39b1a012ce5e5ca940e86bc4d.1407139490.git.hutao@cn.fujitsu.com
State New
Headers show

Commit Message

Hu Tao Aug. 4, 2014, 8:16 a.m. UTC
If user specifies a node number that exceeds the available numa nodes in
emulated system for pc-dimm device, the device will reports an invalid _PXM
to OSPM. Fix it by checking the node value.

Signed-off-by: Hu Tao <hutao@cn.fujitsu.com>
---
 hw/mem/pc-dimm.c | 5 +++++
 1 file changed, 5 insertions(+)

Comments

Michael S. Tsirkin Aug. 4, 2014, 12:22 p.m. UTC | #1
On Mon, Aug 04, 2014 at 04:16:08PM +0800, Hu Tao wrote:
> If user specifies a node number that exceeds the available numa nodes in
> emulated system for pc-dimm device, the device will reports an invalid _PXM
> to OSPM. Fix it by checking the node value.
> 
> Signed-off-by: Hu Tao <hutao@cn.fujitsu.com>
> ---
>  hw/mem/pc-dimm.c | 5 +++++
>  1 file changed, 5 insertions(+)
> 
> diff --git a/hw/mem/pc-dimm.c b/hw/mem/pc-dimm.c
> index 08f49ed..92e276f 100644
> --- a/hw/mem/pc-dimm.c
> +++ b/hw/mem/pc-dimm.c
> @@ -252,6 +252,11 @@ static void pc_dimm_realize(DeviceState *dev, Error **errp)
>          error_setg(errp, "'" PC_DIMM_MEMDEV_PROP "' property is not set");
>          return;
>      }
> +    if (dimm->node >= nb_numa_nodes) {
> +        error_setg(errp, "'" PC_DIMM_NODE_PROP
> +                   "' exceeds numa node number: %" PRId32, nb_numa_nodes);

PRId32 is wrong here, this variable is int, use %d.
Also, this message isn't very clear, I fixed it up
with a patch on top.

> +        return;
> +    }
>  }
>  
>  static MemoryRegion *pc_dimm_get_memory_region(PCDIMMDevice *dimm)
> -- 
> 1.9.3
Hu Tao Aug. 5, 2014, 1:12 a.m. UTC | #2
On Mon, Aug 04, 2014 at 02:22:48PM +0200, Michael S. Tsirkin wrote:
> On Mon, Aug 04, 2014 at 04:16:08PM +0800, Hu Tao wrote:
> > If user specifies a node number that exceeds the available numa nodes in
> > emulated system for pc-dimm device, the device will reports an invalid _PXM
> > to OSPM. Fix it by checking the node value.
> > 
> > Signed-off-by: Hu Tao <hutao@cn.fujitsu.com>
> > ---
> >  hw/mem/pc-dimm.c | 5 +++++
> >  1 file changed, 5 insertions(+)
> > 
> > diff --git a/hw/mem/pc-dimm.c b/hw/mem/pc-dimm.c
> > index 08f49ed..92e276f 100644
> > --- a/hw/mem/pc-dimm.c
> > +++ b/hw/mem/pc-dimm.c
> > @@ -252,6 +252,11 @@ static void pc_dimm_realize(DeviceState *dev, Error **errp)
> >          error_setg(errp, "'" PC_DIMM_MEMDEV_PROP "' property is not set");
> >          return;
> >      }
> > +    if (dimm->node >= nb_numa_nodes) {
> > +        error_setg(errp, "'" PC_DIMM_NODE_PROP
> > +                   "' exceeds numa node number: %" PRId32, nb_numa_nodes);
> 
> PRId32 is wrong here, this variable is int, use %d.
> Also, this message isn't very clear, I fixed it up
> with a patch on top.

Thanks!

> 
> > +        return;
> > +    }
> >  }
> >  
> >  static MemoryRegion *pc_dimm_get_memory_region(PCDIMMDevice *dimm)
> > -- 
> > 1.9.3
diff mbox

Patch

diff --git a/hw/mem/pc-dimm.c b/hw/mem/pc-dimm.c
index 08f49ed..92e276f 100644
--- a/hw/mem/pc-dimm.c
+++ b/hw/mem/pc-dimm.c
@@ -252,6 +252,11 @@  static void pc_dimm_realize(DeviceState *dev, Error **errp)
         error_setg(errp, "'" PC_DIMM_MEMDEV_PROP "' property is not set");
         return;
     }
+    if (dimm->node >= nb_numa_nodes) {
+        error_setg(errp, "'" PC_DIMM_NODE_PROP
+                   "' exceeds numa node number: %" PRId32, nb_numa_nodes);
+        return;
+    }
 }
 
 static MemoryRegion *pc_dimm_get_memory_region(PCDIMMDevice *dimm)