Hi,

On 2021/01/25 0:33, Reinoud Zandijk wrote:
Module Name:    src
Committed By:   reinoud
Date:           Sun Jan 24 15:33:02 UTC 2021

Modified Files:
        src/sys/dev/pci: virtio_pci.c

Log Message:
On error unmap the pci_mapreg_map()d regions using bus_space_unmap() as
suggested by jak@


To generate a diff of this commit:
cvs rdiff -u -r1.22 -r1.23 src/sys/dev/pci/virtio_pci.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

This seems not correct for me. Is the attached patch OK with you?

Thanks,
rin
Index: sys/dev/pci/virtio_pci.c
===================================================================
RCS file: /home/netbsd/src/sys/dev/pci/virtio_pci.c,v
retrieving revision 1.25
diff -p -u -r1.25 virtio_pci.c
--- sys/dev/pci/virtio_pci.c    24 Jan 2021 15:59:35 -0000      1.25
+++ sys/dev/pci/virtio_pci.c    26 Jan 2021 08:47:23 -0000
@@ -444,7 +444,7 @@ virtio_pci_attach_10(device_t self, void
        bus_size_t bars[NMAPREG] = { 0 };
        int bars_idx[NMAPREG] = { 0 };
        struct virtio_pci_cap *caps[] = { &common, &isr, &device, &notify.cap };
-       int i, j = 0, ret = 0;
+       int i, j, ret = 0;
 
        if (virtio_pci_find_cap(psc, VIRTIO_PCI_CAP_COMMON_CFG,
                        &common, sizeof(common)))
@@ -471,7 +471,7 @@ virtio_pci_attach_10(device_t self, void
                        bars[bar] = len;
        }
 
-       for (i = 0; i < __arraycount(bars); i++) {
+       for (i = j = 0; i < __arraycount(bars); i++) {
                int reg;
                pcireg_t type;
                if (bars[i] == 0)
@@ -550,11 +550,12 @@ virtio_pci_attach_10(device_t self, void
 
 err:
        /* undo our pci_mapreg_map()s */ 
-       for (i = 0; i < __arraycount(bars); i++) {
+       for (i = j = 0; i < __arraycount(bars); i++) {
                if (bars[i] == 0)
                        continue;
                bus_space_unmap(psc->sc_bars_iot[j], psc->sc_bars_ioh[j],
                                psc->sc_bars_iosize[j]);
+               j++;
        }
        return ret;
 }

Reply via email to