Hi,

On Sat, Aug 08, 2015 at 05:39:07PM +0200, Christian Schulte wrote:
> While at it. I cannot test this as I do not have corresponding hardware.
> 
> Index: sys/dev/ic/ti.c
> ===================================================================
> RCS file: /cvs/src/sys/dev/ic/ti.c,v
> retrieving revision 1.12
> diff -u -r1.12 ti.c
> --- sys/dev/ic/ti.c   22 Dec 2014 02:28:51 -0000      1.12
> +++ sys/dev/ic/ti.c   8 Aug 2015 15:36:21 -0000

[...]

> @@ -655,6 +655,7 @@
> 
>               if (bus_dmamap_load_mbuf(sc->sc_dmatag, dmamap, m_new,
>                   BUS_DMA_NOWAIT)) {
> +                     m_freem(m_new);
>                       m_freem(m);
>                       return (ENOBUFS);
>               }
> 

There is no need to keep m_freem(m): m is NULL in this if() branch (if
condition outside the diff context). There is also a second faulty
m_freem(m) in this file.

Freeing m_new is need as it was just allocated with pool_get(9) (via
MCLGETI or MGETHDR). m_freem() will return it with pool_put(9).

I also keep to comments spelling correction.

Comments or post-lock OK ?
-- 
Sebastien Marie


Index: dev/ic/ti.c
===================================================================
RCS file: /cvs/src/sys/dev/ic/ti.c,v
retrieving revision 1.15
diff -u -p -r1.15 ti.c
--- dev/ic/ti.c 24 Jun 2015 09:40:54 -0000      1.15
+++ dev/ic/ti.c 9 Aug 2015 07:44:19 -0000
@@ -560,7 +560,7 @@ ti_handle_events(struct ti_softc *sc)
 }
 
 /*
- * Intialize a standard receive ring descriptor.
+ * Initialize a standard receive ring descriptor.
  */
 int
 ti_newbuf_std(struct ti_softc *sc, int i, struct mbuf *m,
@@ -620,7 +620,7 @@ ti_newbuf_std(struct ti_softc *sc, int i
 }
 
 /*
- * Intialize a mini receive ring descriptor. This only applies to
+ * Initialize a mini receive ring descriptor. This only applies to
  * the Tigon 2.
  */
 int
@@ -654,7 +654,7 @@ ti_newbuf_mini(struct ti_softc *sc, int 
 
                if (bus_dmamap_load_mbuf(sc->sc_dmatag, dmamap, m_new,
                    BUS_DMA_NOWAIT)) {
-                       m_freem(m);
+                       m_freem(m_new);
                        return (ENOBUFS);
                }
        } else {
@@ -712,7 +712,7 @@ ti_newbuf_jumbo(struct ti_softc *sc, int
 
                if (bus_dmamap_load_mbuf(sc->sc_dmatag, dmamap, m_new,
                    BUS_DMA_NOWAIT)) {
-                       m_freem(m);
+                       m_freem(m_new);
                        return (ENOBUFS);
                }
        } else {

Reply via email to