summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJia Zhou <zhou.jia2@zte.com.cn>2021-07-29 17:39:18 +0200
committerMichal Privoznik <mprivozn@redhat.com>2021-07-29 17:44:38 +0200
commitbae39ea87133aed886699a423a7ccce2a8f8fd32 (patch)
tree1bd743e7a18c425d5d03f6f193ba238a9424c601
parenta64de8994f5ba34b05d718042a69c066121a531a (diff)
downloadlibvirt-7.6.0-rc2.tar.gz
virnvme: Duplicate index in nested loop in virNVMeDeviceListCreateReAttachListv7.6.0-rc2
When loop in function virNVMeDeviceListCreateReAttachList() there may be reused index @i, this patch fix this by using a new @j. Signed-off-by: Jia Zhou <zhou.jia2@zte.com.cn> Signed-off-by: Yi Wang <wang.yi59@zte.com.cn> Signed-off-by: Michal Privoznik <mprivozn@redhat.com> Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
-rw-r--r--src/util/virnvme.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/src/util/virnvme.c b/src/util/virnvme.c
index 0eda36aa6d..11da76e760 100644
--- a/src/util/virnvme.c
+++ b/src/util/virnvme.c
@@ -397,12 +397,13 @@ virNVMeDeviceListCreateReAttachList(virNVMeDeviceList *activeList,
const virNVMeDevice *d = toReAttachList->devs[i];
g_autoptr(virPCIDevice) pci = NULL;
size_t nused = 0;
+ size_t j;
/* Check if there is any other NVMe device with the same PCI address as
* @d. To simplify this, let's just count how many NVMe devices with
* the same PCI address there are on the @activeList. */
- for (i = 0; i < activeList->count; i++) {
- virNVMeDevice *other = activeList->devs[i];
+ for (j = 0; j < activeList->count; j++) {
+ virNVMeDevice *other = activeList->devs[j];
if (!virPCIDeviceAddressEqual(&d->address, &other->address))
continue;