Source-Changes-HG archive

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

[src/trunk]: src/sys/dev/pci fix mbuf leak on failure (Brainy)



details:   https://anonhg.NetBSD.org/src/rev/e65bcb2cb489
branches:  trunk
changeset: 337792:e65bcb2cb489
user:      christos <christos%NetBSD.org@localhost>
date:      Mon Apr 27 17:38:01 2015 +0000

description:
fix mbuf leak on failure (Brainy)

diffstat:

 sys/dev/pci/hifn7751.c |  5 +++--
 sys/dev/pci/if_bge.c   |  8 +++++---
 sys/dev/pci/if_pcn.c   |  5 +++--
 sys/dev/pci/if_ti.c    |  5 +++--
 4 files changed, 14 insertions(+), 9 deletions(-)

diffs (108 lines):

diff -r 21e62d35134b -r e65bcb2cb489 sys/dev/pci/hifn7751.c
--- a/sys/dev/pci/hifn7751.c    Mon Apr 27 17:36:41 2015 +0000
+++ b/sys/dev/pci/hifn7751.c    Mon Apr 27 17:38:01 2015 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: hifn7751.c,v 1.57 2015/04/13 16:33:25 riastradh Exp $  */
+/*     $NetBSD: hifn7751.c,v 1.58 2015/04/27 17:38:01 christos Exp $   */
 /*     $FreeBSD: hifn7751.c,v 1.5.2.7 2003/10/08 23:52:00 sam Exp $ */
 /*     $OpenBSD: hifn7751.c,v 1.140 2003/08/01 17:55:54 deraadt Exp $  */
 
@@ -48,7 +48,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: hifn7751.c,v 1.57 2015/04/13 16:33:25 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: hifn7751.c,v 1.58 2015/04/27 17:38:01 christos Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -3123,6 +3123,7 @@
                }
                MCLGET(m, M_DONTWAIT);
                if (!(m->m_flags & M_EXT)) {
+                       m_freem(m);
                        m_freem(m0);
                        return (NULL);
                }
diff -r 21e62d35134b -r e65bcb2cb489 sys/dev/pci/if_bge.c
--- a/sys/dev/pci/if_bge.c      Mon Apr 27 17:36:41 2015 +0000
+++ b/sys/dev/pci/if_bge.c      Mon Apr 27 17:38:01 2015 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: if_bge.c,v 1.282 2015/04/13 16:33:25 riastradh Exp $   */
+/*     $NetBSD: if_bge.c,v 1.283 2015/04/27 17:42:20 christos Exp $    */
 
 /*
  * Copyright (c) 2001 Wind River Systems
@@ -79,7 +79,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_bge.c,v 1.282 2015/04/13 16:33:25 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_bge.c,v 1.283 2015/04/27 17:42:20 christos Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -1744,8 +1744,10 @@
        if (!(sc->bge_flags & BGEF_RX_ALIGNBUG))
            m_adj(m_new, ETHER_ALIGN);
        if (bus_dmamap_load_mbuf(sc->bge_dmatag, dmamap, m_new,
-           BUS_DMA_READ|BUS_DMA_NOWAIT))
+           BUS_DMA_READ|BUS_DMA_NOWAIT)) {
+               m_freem(m_new);
                return ENOBUFS;
+       }
        bus_dmamap_sync(sc->bge_dmatag, dmamap, 0, dmamap->dm_mapsize,
            BUS_DMASYNC_PREREAD);
 
diff -r 21e62d35134b -r e65bcb2cb489 sys/dev/pci/if_pcn.c
--- a/sys/dev/pci/if_pcn.c      Mon Apr 27 17:36:41 2015 +0000
+++ b/sys/dev/pci/if_pcn.c      Mon Apr 27 17:38:01 2015 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: if_pcn.c,v 1.59 2015/04/13 16:33:25 riastradh Exp $    */
+/*     $NetBSD: if_pcn.c,v 1.60 2015/04/27 17:40:13 christos Exp $     */
 
 /*
  * Copyright (c) 2001 Wasabi Systems, Inc.
@@ -65,7 +65,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_pcn.c,v 1.59 2015/04/13 16:33:25 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_pcn.c,v 1.60 2015/04/27 17:40:13 christos Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -982,6 +982,7 @@
                                printf("%s: unable to load Tx buffer, "
                                    "error = %d\n", device_xname(sc->sc_dev),
                                    error);
+                               m_freem(m);
                                break;
                        }
                }
diff -r 21e62d35134b -r e65bcb2cb489 sys/dev/pci/if_ti.c
--- a/sys/dev/pci/if_ti.c       Mon Apr 27 17:36:41 2015 +0000
+++ b/sys/dev/pci/if_ti.c       Mon Apr 27 17:38:01 2015 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: if_ti.c,v 1.93 2014/03/29 19:28:25 christos Exp $ */
+/* $NetBSD: if_ti.c,v 1.94 2015/04/27 17:41:26 christos Exp $ */
 
 /*
  * Copyright (c) 1997, 1998, 1999
@@ -81,7 +81,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_ti.c,v 1.93 2014/03/29 19:28:25 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_ti.c,v 1.94 2015/04/27 17:41:26 christos Exp $");
 
 #include "opt_inet.h"
 
@@ -733,6 +733,7 @@
                                BUS_DMA_READ|BUS_DMA_NOWAIT)) != 0) {
                        aprint_error_dev(sc->sc_dev, "can't load recv map, error = %d\n",
                               error);
+                       m_freem(m_new);
                        return (ENOMEM);
                }
        } else {



Home | Main Index | Thread Index | Old Index