Re: [PATCH 5/6] nvram: add nrf51_soc flash read method

2020-06-17 Thread Philippe Mathieu-Daudé
On 6/17/20 7:39 AM, P J P wrote:
> From: Prasad J Pandit 
> 
> Add nrf51_soc mmio read method to avoid NULL pointer dereference
> issue.
> 
> Reported-by: Lei Sun 
> Signed-off-by: Prasad J Pandit 
> ---
>  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,
> 




[PATCH 5/6] nvram: add nrf51_soc flash read method

2020-06-16 Thread P J P
From: Prasad J Pandit 

Add nrf51_soc mmio read method to avoid NULL pointer dereference
issue.

Reported-by: Lei Sun 
Signed-off-by: Prasad J Pandit 
---
 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;
+}
+
 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,
-- 
2.26.2