qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] When updating the PFLASH file contents, we should check for a possible failure of blk_pwrite(). Similar to 3a68829 commit
@ 2020-04-08  0:35 Mansour Ahmadi
  2020-04-08  6:36 ` no-reply
                   ` (3 more replies)
  0 siblings, 4 replies; 6+ messages in thread
From: Mansour Ahmadi @ 2020-04-08  0:35 UTC (permalink / raw)
  To: qemu-devel; +Cc: Mansour Ahmadi

Signed-off-by: Mansour Ahmadi <mansourweb@gmail.com>
---
 hw/block/pflash_cfi01.c | 6 +++++-
 hw/block/pflash_cfi02.c | 6 +++++-
 2 files changed, 10 insertions(+), 2 deletions(-)

diff --git a/hw/block/pflash_cfi01.c b/hw/block/pflash_cfi01.c
index 24f3bce7ef..31319cfd07 100644
--- a/hw/block/pflash_cfi01.c
+++ b/hw/block/pflash_cfi01.c
@@ -399,13 +399,17 @@ static void pflash_update(PFlashCFI01 *pfl, int offset,
                           int size)
 {
     int offset_end;
+    int ret;
     if (pfl->blk) {
         offset_end = offset + size;
         /* widen to sector boundaries */
         offset = QEMU_ALIGN_DOWN(offset, BDRV_SECTOR_SIZE);
         offset_end = QEMU_ALIGN_UP(offset_end, BDRV_SECTOR_SIZE);
-        blk_pwrite(pfl->blk, offset, pfl->storage + offset,
+        ret = blk_pwrite(pfl->blk, offset, pfl->storage + offset,
                    offset_end - offset, 0);
+	if (ret < 0) {
+            error_report("Could not update PFLASH: %s", strerror(-ret));
+        }
     }
 }
 
diff --git a/hw/block/pflash_cfi02.c b/hw/block/pflash_cfi02.c
index 12f18d401a..fee5b3497c 100644
--- a/hw/block/pflash_cfi02.c
+++ b/hw/block/pflash_cfi02.c
@@ -393,13 +393,17 @@ static uint64_t pflash_read(void *opaque, hwaddr offset, unsigned int width)
 static void pflash_update(PFlashCFI02 *pfl, int offset, int size)
 {
     int offset_end;
+    int ret;
     if (pfl->blk) {
         offset_end = offset + size;
         /* widen to sector boundaries */
         offset = QEMU_ALIGN_DOWN(offset, BDRV_SECTOR_SIZE);
         offset_end = QEMU_ALIGN_UP(offset_end, BDRV_SECTOR_SIZE);
-        blk_pwrite(pfl->blk, offset, pfl->storage + offset,
+        ret = blk_pwrite(pfl->blk, offset, pfl->storage + offset,
                    offset_end - offset, 0);
+	if (ret < 0) {
+	    error_report("Could not update PFLASH: %s", strerror(-ret));
+        }
     }
 }
 
-- 
2.16.2



^ permalink raw reply related	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2020-04-12 21:36 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-04-08  0:35 [PATCH] When updating the PFLASH file contents, we should check for a possible failure of blk_pwrite(). Similar to 3a68829 commit Mansour Ahmadi
2020-04-08  6:36 ` no-reply
2020-04-08  6:39 ` no-reply
2020-04-08  6:44 ` no-reply
2020-04-08  8:08 ` Philippe Mathieu-Daudé
2020-04-12 21:35   ` Philippe Mathieu-Daudé

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).