From: Jia Zhou Date: Thu, 29 Jul 2021 15:39:18 +0000 (+0200) Subject: virnvme: Duplicate index in nested loop in virNVMeDeviceListCreateReAttachList X-Git-Tag: v7.6.0-rc2^0 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=bae39ea87133aed886699a423a7ccce2a8f8fd32;p=thirdparty%2Flibvirt.git virnvme: Duplicate index in nested loop in virNVMeDeviceListCreateReAttachList 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 Signed-off-by: Yi Wang Signed-off-by: Michal Privoznik Reviewed-by: Michal Privoznik --- 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;