[SeaBIOS] [PATCH 3/5] nvme: fix reversed loop condition in cmd_readwrite

Daniel Verkamp daniel at drv.nu
Fri Feb 24 07:27:55 CET 2017


It looks like the intent was to exit the loop if a command failed, but
the current code would actually continue looping in that case.

Signed-off-by: Daniel Verkamp <daniel at drv.nu>
---
 src/hw/nvme.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/hw/nvme.c b/src/hw/nvme.c
index c194f9f..97b05cb 100644
--- a/src/hw/nvme.c
+++ b/src/hw/nvme.c
@@ -571,7 +571,7 @@ nvme_cmd_readwrite(struct nvme_namespace *ns, struct disk_op_s *op, int write)
     u16 const max_blocks = NVME_PAGE_SIZE / ns->block_size;
     u16 i;
 
-    for (i = 0; i < op->count || res != DISK_RET_SUCCESS;) {
+    for (i = 0; i < op->count && res == DISK_RET_SUCCESS;) {
         u16 blocks_remaining = op->count - i;
         u16 blocks = blocks_remaining < max_blocks ? blocks_remaining
                                                    : max_blocks;
-- 
2.11.1




More information about the SeaBIOS mailing list