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 anyhow. Signed-off-by: Wolfram Sang <wsa+renesas@xxxxxxxxxxxxxxxxxxxx> --- hw/nvram/eeprom_at24c.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/hw/nvram/eeprom_at24c.c b/hw/nvram/eeprom_at24c.c index 22183f5360..ccf78b25e4 100644 --- a/hw/nvram/eeprom_at24c.c +++ b/hw/nvram/eeprom_at24c.c @@ -121,6 +121,11 @@ int at24c_eeprom_init(I2CSlave *i2c) { EEPROMState *ee = AT24C_EE(i2c); + if (!ee->rsize) { + ERR("rom-size not allowed to be 0\n"); + exit(1); + } + ee->mem = g_malloc0(ee->rsize); if (ee->blk) { -- 2.11.0