]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
virnvme: Duplicate index in nested loop in virNVMeDeviceListCreateReAttachList v7.6.0-rc2
authorJia Zhou <zhou.jia2@zte.com.cn>
Thu, 29 Jul 2021 15:39:18 +0000 (17:39 +0200)
committerMichal Privoznik <mprivozn@redhat.com>
Thu, 29 Jul 2021 15:44:38 +0000 (17:44 +0200)
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>
src/util/virnvme.c

index 0eda36aa6d19f5aae33ecd43b5d5c95e343a1977..11da76e76029be815a503ea6569abcee964c6715 100644 (file)
@@ -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;