Author: bschmidt
Date: Sat Apr 16 11:11:22 2011
New Revision: 220710
URL: http://svn.freebsd.org/changeset/base/220710

Log:
  Prevent double-free, also use the same error codes as OpenBSD.

Modified:
  head/sys/dev/iwn/if_iwn.c

Modified: head/sys/dev/iwn/if_iwn.c
==============================================================================
--- head/sys/dev/iwn/if_iwn.c   Sat Apr 16 11:06:09 2011        (r220709)
+++ head/sys/dev/iwn/if_iwn.c   Sat Apr 16 11:11:22 2011        (r220710)
@@ -1294,7 +1294,7 @@ iwn_alloc_rx_ring(struct iwn_softc *sc, 
                if (data->m == NULL) {
                        device_printf(sc->sc_dev,
                            "%s: could not allocate rx mbuf\n", __func__);
-                       error = ENOMEM;
+                       error = ENOBUFS;
                        goto fail;
                }
 
@@ -1305,8 +1305,6 @@ iwn_alloc_rx_ring(struct iwn_softc *sc, 
                        device_printf(sc->sc_dev,
                            "%s: bus_dmamap_load failed, error %d\n",
                            __func__, error);
-                       m_freem(data->m);
-                       error = ENOMEM; /* XXX unique code */
                        goto fail;
                }
 
@@ -1361,6 +1359,7 @@ iwn_free_rx_ring(struct iwn_softc *sc, s
                            BUS_DMASYNC_POSTREAD);
                        bus_dmamap_unload(ring->data_dmat, data->map);
                        m_freem(data->m);
+                       data->m = NULL;
                }
                if (data->map != NULL)
                        bus_dmamap_destroy(ring->data_dmat, data->map);
_______________________________________________
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"

Reply via email to