Source-Changes-HG archive

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

[src/netbsd-6]: src/sys/dev/usb Pull up following revision(s) (requested by s...



details:   https://anonhg.NetBSD.org/src/rev/b2d708d19690
branches:  netbsd-6
changeset: 775756:b2d708d19690
user:      bouyer <bouyer%NetBSD.org@localhost>
date:      Sat Apr 20 09:52:19 2013 +0000

description:
Pull up following revision(s) (requested by skrll in ticket #864):
        sys/dev/usb/ohci.c: revision 1.234
        sys/dev/usb/ohci.c: revision 1.236
Don't leak memory if ohci_alloc_std_chain fails.
When dumping the done list in ohci_softintr / OHCI_DEBUG use the correct
list next pointer.
PR/33450 and part of PR/35379.

diffstat:

 sys/dev/usb/ohci.c |  29 ++++++++++++++++++-----------
 1 files changed, 18 insertions(+), 11 deletions(-)

diffs (98 lines):

diff -r 3bc03102a9aa -r b2d708d19690 sys/dev/usb/ohci.c
--- a/sys/dev/usb/ohci.c        Sun Mar 31 22:24:10 2013 +0000
+++ b/sys/dev/usb/ohci.c        Sat Apr 20 09:52:19 2013 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: ohci.c,v 1.218.8.1 2013/01/05 23:30:04 riz Exp $       */
+/*     $NetBSD: ohci.c,v 1.218.8.2 2013/04/20 09:52:19 bouyer Exp $    */
 /*     $FreeBSD: src/sys/dev/usb/ohci.c,v 1.22 1999/11/17 22:33:40 n_hibma Exp $       */
 
 /*
@@ -41,7 +41,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ohci.c,v 1.218.8.1 2013/01/05 23:30:04 riz Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ohci.c,v 1.218.8.2 2013/04/20 09:52:19 bouyer Exp $");
 
 #include "opt_usb.h"
 
@@ -100,10 +100,8 @@
 Static ohci_soft_itd_t *ohci_alloc_sitd(ohci_softc_t *);
 Static void            ohci_free_sitd(ohci_softc_t *,ohci_soft_itd_t *);
 
-#if 0
 Static void            ohci_free_std_chain(ohci_softc_t *, ohci_soft_td_t *,
                                            ohci_soft_td_t *);
-#endif
 Static usbd_status     ohci_alloc_std_chain(struct ohci_pipe *,
                            ohci_softc_t *, int, int, usbd_xfer_handle,
                            ohci_soft_td_t *, ohci_soft_td_t **);
@@ -566,11 +564,13 @@
        return (USBD_NORMAL_COMPLETION);
 
  nomem:
-       /* XXX free chain */
+
+       /* Don't free sp - let the caller do that */
+       ohci_free_std_chain(sc, sp->nexttd, NULL);
+
        return (USBD_NOMEM);
 }
 
-#if 0
 Static void
 ohci_free_std_chain(ohci_softc_t *sc, ohci_soft_td_t *std,
                    ohci_soft_td_t *stdend)
@@ -582,7 +582,6 @@
                ohci_free_std(sc, std);
        }
 }
-#endif
 
 ohci_soft_itd_t *
 ohci_alloc_sitd(ohci_softc_t *sc)
@@ -1303,7 +1302,8 @@
 #ifdef OHCI_DEBUG
        if (ohcidebug > 10) {
                DPRINTF(("ohci_process_done: TD done:\n"));
-               ohci_dump_tds(sc, sdone);
+               for (std = sdone; std; std = std->dnext)
+                       ohci_dump_td(sc, std);  
        }
 #endif
 
@@ -1384,7 +1384,8 @@
 #ifdef OHCI_DEBUG
        if (ohcidebug > 10) {
                DPRINTF(("ohci_softintr: ITD done:\n"));
-               ohci_dump_itds(sc, sidone);
+               for (sitd = sidone; sitd; sitd = sitd->dnext)
+                       ohci_dump_itd(sc, sitd);        
        }
 #endif
 
@@ -1716,9 +1717,12 @@
 
                err = ohci_alloc_std_chain(opipe, sc, len, isread, xfer,
                          std, &stat);
+               if (err) {
+                       /* stat is unchanged if error */
+                       goto bad3;
+               }
                stat = stat->nexttd; /* point at free TD */
-               if (err)
-                       goto bad3;
+
                /* Start toggle at 1 and then use the carried toggle. */
                std->td.td_flags &= HTOO32(~OHCI_TD_TOGGLE_MASK);
                std->td.td_flags |= HTOO32(OHCI_TD_TOGGLE_1);
@@ -2970,6 +2974,9 @@
        data = opipe->tail.td;
        err = ohci_alloc_std_chain(opipe, sc, len, isread, xfer,
                  data, &tail);
+       if (err)
+               return err;
+       
        /* We want interrupt at the end of the transfer. */
        tail->td.td_flags &= HTOO32(~OHCI_TD_INTR_MASK);
        tail->td.td_flags |= HTOO32(OHCI_TD_SET_DI(1));



Home | Main Index | Thread Index | Old Index