[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 23/26] migration: Fix migration_channel_read_peek() error path
From: |
peterx |
Subject: |
[PULL 23/26] migration: Fix migration_channel_read_peek() error path |
Date: |
Thu, 4 Jan 2024 12:32:08 +0800 |
From: Avihai Horon <avihaih@nvidia.com>
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>
Reviewed-by: Fabiano Rosas <farosas@suse.de>
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Link: https://lore.kernel.org/r/20231231093016.14204-10-avihaih@nvidia.com
Signed-off-by: Peter Xu <peterx@redhat.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.41.0
- [PULL 13/26] tests/qtest: precopy migration with suspend, (continued)
- [PULL 13/26] tests/qtest: precopy migration with suspend, peterx, 2024/01/03
- [PULL 14/26] tests/qtest: postcopy migration with suspend, peterx, 2024/01/03
- [PULL 15/26] migration: Remove migrate_max_downtime() declaration, peterx, 2024/01/03
- [PULL 17/26] migration: Refactor migration_incoming_setup(), peterx, 2024/01/03
- [PULL 16/26] migration: Remove nulling of hostname in migrate_init(), peterx, 2024/01/03
- [PULL 19/26] migration/multifd: Fix error message in multifd_recv_initial_packet(), peterx, 2024/01/03
- [PULL 18/26] migration: Remove errp parameter in migration_fd_process_incoming(), peterx, 2024/01/03
- [PULL 20/26] migration/multifd: Simplify multifd_channel_connect() if else statement, peterx, 2024/01/03
- [PULL 21/26] migration/multifd: Fix leaking of Error in TLS error flow, peterx, 2024/01/03
- [PULL 22/26] migration/multifd: Remove error_setg() in migration_ioc_process_incoming(), peterx, 2024/01/03
- [PULL 23/26] migration: Fix migration_channel_read_peek() error path,
peterx <=
- [PULL 25/26] migration/multifd: Remove unnecessary usage of local Error, peterx, 2024/01/03
- [PULL 24/26] migration: Remove unnecessary usage of local Error, peterx, 2024/01/03
- [PULL 26/26] migration: fix coverity migrate_mode finding, peterx, 2024/01/03
- Re: [PULL 00/26] Migration 20240104 patches, Peter Maydell, 2024/01/05
- Re: [PULL 00/26] Migration 20240104 patches, Peter Xu, 2024/01/07
- Re: [PULL 00/26] Migration 20240104 patches, Stefan Hajnoczi, 2024/01/07
- Re: [PULL 00/26] Migration 20240104 patches, Peter Maydell, 2024/01/07
- Re: [PULL 00/26] Migration 20240104 patches, Stefan Hajnoczi, 2024/01/07
- Re: [PULL 00/26] Migration 20240104 patches, Peter Xu, 2024/01/07
- Re: [PULL 00/26] Migration 20240104 patches, Peter Xu, 2024/01/07