Skip to contentSkip to conversation

ppc/pnv: Fix check on block device before updating drive contents

PATCH Applied Cédric Le Goater 2 participants 2 messages Nov 2, 2021 – Nov 3, 2021

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ppc/pnv: Fix check on block device before updating drive contents

Test is wrong and the backend can never updated. It could have led to a QEMU crash but since the firmware deactivates flash access if a valid layout is not detected, it went unnoticed.

Reported-by Coverity CID 1465223
Fixes 35dde5766211 ("ppc/pnv: Add a PNOR model")
---
 hw/ppc/pnv_pnor.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
hw/ppc/pnv_pnor.c +1 -1
index 5ef1cf2afbe1..83ecccca28df 100644
@@ -36,7 +36,7 @@ static void pnv_pnor_update(PnvPnor *s, int offset, int size)
     int offset_end;
     int ret;
 
-    if (s->blk) {
+    if (!s->blk || !blk_is_writable(s->blk)) {
         return;
     }
 
Signature · 1 line
2.31.1
Applied
#1 lore raw
Quoted 7 lines · Cédric Le Goater

Test is wrong and the backend can never updated. It could have led to a QEMU crash but since the firmware deactivates flash access if a valid layout is not detected, it went unnoticed.

Reported-by Coverity CID 1465223
Fixes 35dde5766211 ("ppc/pnv: Add a PNOR model")

Applied to ppc-for-6.2, thanks.

Quoted 17 lines
---
 hw/ppc/pnv_pnor.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
hw/ppc/pnv_pnor.c +1 -1
index 5ef1cf2afbe1..83ecccca28df 100644
@@ -36,7 +36,7 @@ static void pnv_pnor_update(PnvPnor *s, int offset, int size)
     int offset_end;
     int ret;
 
-    if (s->blk) {
+    if (!s->blk || !blk_is_writable(s->blk)) {
         return;
     }
 
Signature · 4 lines
David Gibson			| I'll have my music baroque, and my code
david AT gibson.dropbear.id.au	| minimalist, thank you.  NOT _the_ _other_
				| _way_ _around_!
http://www.ozlabs.org/~dgibson