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.

Modified files:

Index: src/sys/dev/pci/virtio_pci.c
diff -u src/sys/dev/pci/virtio_pci.c:1.22 src/sys/dev/pci/virtio_pci.c:1.23
--- src/sys/dev/pci/virtio_pci.c:1.22	Sun Jan 24 14:33:49 2021
+++ src/sys/dev/pci/virtio_pci.c	Sun Jan 24 15:33:02 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: virtio_pci.c,v 1.22 2021/01/24 14:33:49 reinoud Exp $ */
+/* $NetBSD: virtio_pci.c,v 1.23 2021/01/24 15:33:02 reinoud Exp $ */
 
 /*
  * Copyright (c) 2020 The NetBSD Foundation, Inc.
@@ -28,7 +28,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: virtio_pci.c,v 1.22 2021/01/24 14:33:49 reinoud Exp $");
+__KERNEL_RCSID(0, "$NetBSD: virtio_pci.c,v 1.23 2021/01/24 15:33:02 reinoud Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -555,7 +555,13 @@ virtio_pci_attach_10(device_t self, void
 	return 0;
 
 err:
-	/* there is no pci_mapreg_unmap() */
+	/* undo our pci_mapreg_map()s */ 
+	for (i = 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]);
+	}
 	return ret;
 }
 

Reply via email to