qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2] block/file-posix: fix wps checking in raw_co_prw
@ 2023-06-07 18:57 Sam Li
  2023-06-08  1:29 ` Damien Le Moal
  0 siblings, 1 reply; 3+ messages in thread
From: Sam Li @ 2023-06-07 18:57 UTC (permalink / raw)
  To: qemu-devel
  Cc: qemu-block, dlemoal, Hanna Reitz, stefanha, Kevin Wolf,
	dmitry.fomichev, hare, Sam Li

If the write operation fails and the wps is NULL, then accessing it will
lead to data corruption.

Solving the issue by adding a nullptr checking in get_zones_wp() where
the wps is used.

This issue is found by Peter Maydell using the Coverity Tool (CID
1512459).

Signed-off-by: Sam Li <faithilikerun@gmail.com>
---
 block/file-posix.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/block/file-posix.c b/block/file-posix.c
index ac1ed54811..4a6c71c7f5 100644
--- a/block/file-posix.c
+++ b/block/file-posix.c
@@ -2523,7 +2523,7 @@ out:
             }
         }
     } else {
-        if (type & (QEMU_AIO_WRITE | QEMU_AIO_ZONE_APPEND)) {
+        if (type & (QEMU_AIO_WRITE | QEMU_AIO_ZONE_APPEND) && wps) {
             update_zones_wp(bs, s->fd, 0, 1);
         }
     }
-- 
2.40.1



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

end of thread, other threads:[~2023-06-08  2:45 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-06-07 18:57 [PATCH v2] block/file-posix: fix wps checking in raw_co_prw Sam Li
2023-06-08  1:29 ` Damien Le Moal
2023-06-08  2:44   ` Sam Li

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).