[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 09/11] migration: Fix migration_channel_read_peek() error path
From: |
Avihai Horon |
Subject: |
[PATCH 09/11] migration: Fix migration_channel_read_peek() error path |
Date: |
Sun, 31 Dec 2023 11:30:14 +0200 |
migration_channel_read_peek() calls qio_channel_readv_full() and handles
both cases of return value == 0 and return value < 0 the same way, by
calling error_setg() with errp. However, if return value < 0, errp is
already set, so calling error_setg() with errp will lead to an assert.
Fix it by handling these cases separately, calling error_setg() with
errp only in return value == 0 case.
Fixes: 6720c2b32725 ("migration: check magic value for deciding the mapping of
channels")
Signed-off-by: Avihai Horon <avihaih@nvidia.com>
---
migration/channel.c | 9 ++++++---
1 file changed, 6 insertions(+), 3 deletions(-)
diff --git a/migration/channel.c b/migration/channel.c
index ca3319a309..f9de064f3b 100644
--- a/migration/channel.c
+++ b/migration/channel.c
@@ -117,9 +117,12 @@ int migration_channel_read_peek(QIOChannel *ioc,
len = qio_channel_readv_full(ioc, &iov, 1, NULL, NULL,
QIO_CHANNEL_READ_FLAG_MSG_PEEK, errp);
- if (len <= 0 && len != QIO_CHANNEL_ERR_BLOCK) {
- error_setg(errp,
- "Failed to peek at channel");
+ if (len < 0 && len != QIO_CHANNEL_ERR_BLOCK) {
+ return -1;
+ }
+
+ if (len == 0) {
+ error_setg(errp, "Failed to peek at channel");
return -1;
}
--
2.26.3
- [PATCH 01/11] migration: Remove migrate_max_downtime() declaration, (continued)
- [PATCH 01/11] migration: Remove migrate_max_downtime() declaration, Avihai Horon, 2023/12/31
- [PATCH 02/11] migration: Remove nulling of hostname in migrate_init(), Avihai Horon, 2023/12/31
- [PATCH 03/11] migration: Refactor migration_incoming_setup(), Avihai Horon, 2023/12/31
- [PATCH 04/11] migration: Remove errp parameter in migration_fd_process_incoming(), Avihai Horon, 2023/12/31
- [PATCH 05/11] migration/multifd: Fix error message in multifd_recv_initial_packet(), Avihai Horon, 2023/12/31
- [PATCH 06/11] migration/multifd: Simplify multifd_channel_connect() if else statement, Avihai Horon, 2023/12/31
- [PATCH 07/11] migration/multifd: Fix leaking of Error in TLS error flow, Avihai Horon, 2023/12/31
- [PATCH 08/11] migration/multifd: Remove error_setg() in migration_ioc_process_incoming(), Avihai Horon, 2023/12/31
- [PATCH 11/11] migration/multifd: Remove unnecessary usage of local Error, Avihai Horon, 2023/12/31
- [PATCH 10/11] migration: Remove unnecessary usage of local Error, Avihai Horon, 2023/12/31
- [PATCH 09/11] migration: Fix migration_channel_read_peek() error path,
Avihai Horon <=