diff mbox series

[v5,1/2] hw/block: m25p80: Don't write to flash if write is disabled

Message ID 1608688825-81519-1-git-send-email-bmeng.cn@gmail.com
State New
Headers show
Series [v5,1/2] hw/block: m25p80: Don't write to flash if write is disabled | expand

Commit Message

Bin Meng Dec. 23, 2020, 2 a.m. UTC
From: Bin Meng <bin.meng@windriver.com>

When write is disabled, the write to flash should be avoided
in flash_write8().

Fixes: 82a2499011a7 ("m25p80: Initial implementation of SPI flash device")
Signed-off-by: Bin Meng <bin.meng@windriver.com>
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Reviewed-by: Francisco Iglesias <frasse.iglesias@gmail.com>

---

(no changes since v2)

Changes in v2:
- new patch: honor write enable flag in flash write

 hw/block/m25p80.c | 1 +
 1 file changed, 1 insertion(+)

Comments

Bin Meng Jan. 5, 2021, 3:50 a.m. UTC | #1
On Wed, Dec 23, 2020 at 10:00 AM Bin Meng <bmeng.cn@gmail.com> wrote:
>
> From: Bin Meng <bin.meng@windriver.com>
>
> When write is disabled, the write to flash should be avoided
> in flash_write8().
>
> Fixes: 82a2499011a7 ("m25p80: Initial implementation of SPI flash device")
> Signed-off-by: Bin Meng <bin.meng@windriver.com>
> Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
> Reviewed-by: Francisco Iglesias <frasse.iglesias@gmail.com>
>
> ---
>
> (no changes since v2)
>
> Changes in v2:
> - new patch: honor write enable flag in flash write
>
>  hw/block/m25p80.c | 1 +
>  1 file changed, 1 insertion(+)
>

Ping?
Alistair Francis Jan. 5, 2021, 9:13 p.m. UTC | #2
On Mon, Jan 4, 2021 at 7:50 PM Bin Meng <bmeng.cn@gmail.com> wrote:
>
> On Wed, Dec 23, 2020 at 10:00 AM Bin Meng <bmeng.cn@gmail.com> wrote:
> >
> > From: Bin Meng <bin.meng@windriver.com>
> >
> > When write is disabled, the write to flash should be avoided
> > in flash_write8().
> >
> > Fixes: 82a2499011a7 ("m25p80: Initial implementation of SPI flash device")
> > Signed-off-by: Bin Meng <bin.meng@windriver.com>
> > Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
> > Reviewed-by: Francisco Iglesias <frasse.iglesias@gmail.com>
> >
> > ---
> >
> > (no changes since v2)
> >
> > Changes in v2:
> > - new patch: honor write enable flag in flash write
> >
> >  hw/block/m25p80.c | 1 +
> >  1 file changed, 1 insertion(+)
> >
>
> Ping?

Thanks!

Applied to riscv-to-apply.next

Alistair

>
diff mbox series

Patch

diff --git a/hw/block/m25p80.c b/hw/block/m25p80.c
index c45afdd..29598b4 100644
--- a/hw/block/m25p80.c
+++ b/hw/block/m25p80.c
@@ -600,6 +600,7 @@  void flash_write8(Flash *s, uint32_t addr, uint8_t data)
 
     if (!s->write_enable) {
         qemu_log_mask(LOG_GUEST_ERROR, "M25P80: write with write protect!\n");
+        return;
     }
 
     if ((prev ^ data) & data) {