Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/arch/xen/xen destroy dma maps in xennetback_xenbus_destr...



details:   https://anonhg.NetBSD.org/src/rev/86b4e7b7dc33
branches:  trunk
changeset: 932183:86b4e7b7dc33
user:      jdolecek <jdolecek%NetBSD.org@localhost>
date:      Fri May 01 19:59:47 2020 +0000

description:
destroy dma maps in xennetback_xenbus_destroy() to avoid memory leak
when xvif(4) is destroyed

diffstat:

 sys/arch/xen/xen/xennetback_xenbus.c |  13 +++++++++++--
 1 files changed, 11 insertions(+), 2 deletions(-)

diffs (34 lines):

diff -r 70c865d67a8e -r 86b4e7b7dc33 sys/arch/xen/xen/xennetback_xenbus.c
--- a/sys/arch/xen/xen/xennetback_xenbus.c      Fri May 01 19:56:08 2020 +0000
+++ b/sys/arch/xen/xen/xennetback_xenbus.c      Fri May 01 19:59:47 2020 +0000
@@ -1,4 +1,4 @@
-/*      $NetBSD: xennetback_xenbus.c,v 1.100 2020/05/01 19:53:17 jdolecek Exp $      */
+/*      $NetBSD: xennetback_xenbus.c,v 1.101 2020/05/01 19:59:47 jdolecek Exp $      */
 
 /*
  * Copyright (c) 2006 Manuel Bouyer.
@@ -25,7 +25,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: xennetback_xenbus.c,v 1.100 2020/05/01 19:53:17 jdolecek Exp $");
+__KERNEL_RCSID(0, "$NetBSD: xennetback_xenbus.c,v 1.101 2020/05/01 19:59:47 jdolecek Exp $");
 
 #include "opt_xen.h"
 
@@ -386,6 +386,15 @@
        evcnt_detach(&xneti->xni_cnt_rx_cksum_blank);
        evcnt_detach(&xneti->xni_cnt_rx_cksum_undefer);
 
+       /* Destroy DMA maps */
+       for (int i = 0; i < __arraycount(xneti->xni_xstate); i++) {
+               if (xneti->xni_xstate[i].xs_dmamap != NULL) {
+                       bus_dmamap_destroy(xneti->xni_xbusd->xbusd_dmat,
+                           xneti->xni_xstate[i].xs_dmamap);
+                       xneti->xni_xstate[i].xs_dmamap = NULL;
+               }
+       }
+
        if (xneti->xni_txring.sring) {
                op.host_addr = xneti->xni_tx_ring_va;
                op.handle = xneti->xni_tx_ring_handle;



Home | Main Index | Thread Index | Old Index