[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 26/26] migration: fix coverity migrate_mode finding
From: |
peterx |
Subject: |
[PULL 26/26] migration: fix coverity migrate_mode finding |
Date: |
Thu, 4 Jan 2024 12:32:11 +0800 |
From: Steve Sistare <steven.sistare@oracle.com>
Coverity diagnoses a possible out-of-range array index here ...
static GSList *migration_blockers[MIG_MODE__MAX];
fill_source_migration_info() {
GSList *cur_blocker = migration_blockers[migrate_mode()];
... because it does not know that MIG_MODE__MAX will never be returned as
a migration mode. To fix, assert so in migrate_mode().
Fixes: fa3673e497a1 ("migration: per-mode blockers")
Reported-by: Peter Maydell <peter.maydell@linaro.org>
Suggested-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Steve Sistare <steven.sistare@oracle.com>
Reviewed-by: Fabiano Rosas <farosas@suse.de>
Link:
https://lore.kernel.org/r/1699907025-215450-1-git-send-email-steven.sistare@oracle.com
Signed-off-by: Peter Xu <peterx@redhat.com>
---
migration/options.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/migration/options.c b/migration/options.c
index 8d8ec73ad9..3e3e0b93b4 100644
--- a/migration/options.c
+++ b/migration/options.c
@@ -833,8 +833,10 @@ uint64_t migrate_max_postcopy_bandwidth(void)
MigMode migrate_mode(void)
{
MigrationState *s = migrate_get_current();
+ MigMode mode = s->parameters.mode;
- return s->parameters.mode;
+ assert(mode >= 0 && mode < MIG_MODE__MAX);
+ return mode;
}
int migrate_multifd_channels(void)
--
2.41.0
- [PULL 17/26] migration: Refactor migration_incoming_setup(), (continued)
- [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, 2024/01/03
- [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 <=
- 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
- Re: [PULL 00/26] Migration 20240104 patches, Peter Maydell, 2024/01/08