Re: [PATCH v2 1/3] nvram: at24c: prevent segfault by checking "rom-size"

2018-03-19 Thread Philippe Mathieu-Daudé
CSlave *i2c) > { > EEPROMState *ee = AT24C_EE(i2c); > > +if (!ee->rsize) { > +ERR("rom-size not allowed to be 0\n"); You can directly use error_report() in this patch. Reviewed-by: Philippe Mathieu-Daudé <f4...@amsat.org> > +exit(1); > +} > + > ee->mem = g_malloc0(ee->rsize); > > if (ee->blk) { >

Re: [PATCH v2 2/3] nvram: at24c: use a sane default for "rom-size"

2018-03-19 Thread Philippe Mathieu-Daudé
On 03/19/2018 10:31 PM, Wolfram Sang wrote: > 0 as "rom-size" will lead to an error message. Let's use the size of a > small 24c01 which has 128 byte. > > Signed-off-by: Wolfram Sang <wsa+rene...@sang-engineering.com> Reviewed-by: Philippe Mathieu-Daudé <f4..

Re: [Qemu-devel] [PATCH 3/3] nvram: at24c: use a sane default for "rom-size"

2018-03-18 Thread Philippe Mathieu-Daudé
Hi Wolfram, On 03/13/2018 09:16 PM, Wolfram Sang wrote: > Hi Philippe, > >>> static Property at24c_eeprom_props[] = { >>> -DEFINE_PROP_UINT32("rom-size", EEPROMState, rsize, 0), >>> +DEFINE_PROP_UINT32("rom-size", EEPROMState, rsize, 128), >> >> This patch should goes before your 2/3 in

Re: [Qemu-devel] [PATCH 2/3] nvram: at24c: prevent segfault by checking "rom-size"

2018-03-13 Thread Philippe Mathieu-Daudé
On 03/12/2018 10:42 PM, Wolfram Sang wrote: > The value for "rom-size" is used as a divisor, so it must not be 0 or it > will segfault. A size of 0 wouldn't make sense as well. > > Signed-off-by: Wolfram Sang > --- > hw/nvram/eeprom_at24c.c | 5 + > 1 file

Re: [Qemu-devel] [PATCH 1/3] nvram: at24c: remove doubled prefix for ERR

2018-03-13 Thread Philippe Mathieu-Daudé
Hi Wolfram, On 03/12/2018 10:42 PM, Wolfram Sang wrote: > The ERR macro already has the TYPE_AT24C_EE prefix, no need to repeat in > the error message. > > Signed-off-by: Wolfram Sang > --- > hw/nvram/eeprom_at24c.c | 11 --- > 1 file changed, 4

Re: [Qemu-devel] [PATCH 3/3] nvram: at24c: use a sane default for "rom-size"

2018-03-13 Thread Philippe Mathieu-Daudé
for this value? Such AT24C_ROMSIZE_MIN. With a #define you can add: Reviewed-by: Philippe Mathieu-Daudé <f4...@amsat.org> > DEFINE_PROP_BOOL("writable", EEPROMState, writable, true), > DEFINE_PROP_DRIVE("drive", EEPROMState, blk), > DEFINE_PROP_END_OF_LIST() >