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 <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>
This commit is contained in:
Jia Zhou 2021-07-29 17:39:18 +02:00 committed by Michal Privoznik
parent a64de8994f
commit bae39ea871

View 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;