Message ID | 20200617053934.122642-6-ppandit@redhat.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | Add various undefined MMIO r/w functions | expand |
On 6/17/20 7:39 AM, P J P wrote: > From: Prasad J Pandit <pjp@fedoraproject.org> > > Add nrf51_soc mmio read method to avoid NULL pointer dereference > issue. > > Reported-by: Lei Sun <slei.casper@gmail.com> > Signed-off-by: Prasad J Pandit <pjp@fedoraproject.org> > --- > hw/nvram/nrf51_nvm.c | 7 +++++++ > 1 file changed, 7 insertions(+) > > diff --git a/hw/nvram/nrf51_nvm.c b/hw/nvram/nrf51_nvm.c > index f2283c1a8d..e813c7ec72 100644 > --- a/hw/nvram/nrf51_nvm.c > +++ b/hw/nvram/nrf51_nvm.c > @@ -274,6 +274,12 @@ static const MemoryRegionOps io_ops = { > }; > > > +static uint64_t flash_read(void *opaque, hwaddr addr, unsigned size) > +{ > + qemu_log_mask(LOG_UNIMP, "%s not implemented\n", __func__); > + return 0; This is a ROM device, shouldn't we return this instead? return ldl_le_p(s->storage + offset); > +} > + > static void flash_write(void *opaque, hwaddr offset, uint64_t value, > unsigned int size) > { > @@ -300,6 +306,7 @@ static void flash_write(void *opaque, hwaddr offset, uint64_t value, > > > static const MemoryRegionOps flash_ops = { > + .read = flash_read, > .write = flash_write, > .valid.min_access_size = 4, > .valid.max_access_size = 4, >
diff --git a/hw/nvram/nrf51_nvm.c b/hw/nvram/nrf51_nvm.c index f2283c1a8d..e813c7ec72 100644 --- a/hw/nvram/nrf51_nvm.c +++ b/hw/nvram/nrf51_nvm.c @@ -274,6 +274,12 @@ static const MemoryRegionOps io_ops = { }; +static uint64_t flash_read(void *opaque, hwaddr addr, unsigned size) +{ + qemu_log_mask(LOG_UNIMP, "%s not implemented\n", __func__); + return 0; +} + static void flash_write(void *opaque, hwaddr offset, uint64_t value, unsigned int size) { @@ -300,6 +306,7 @@ static void flash_write(void *opaque, hwaddr offset, uint64_t value, static const MemoryRegionOps flash_ops = { + .read = flash_read, .write = flash_write, .valid.min_access_size = 4, .valid.max_access_size = 4,