Source-Changes-HG archive

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

[src/nick-nhusb]: src/sys/dev/usb Don't leak memory in *_alloc_*td_chain if a...



details:   https://anonhg.NetBSD.org/src/rev/e3d5d2d6294a
branches:  nick-nhusb
changeset: 804641:e3d5d2d6294a
user:      skrll <skrll%NetBSD.org@localhost>
date:      Sat Apr 16 15:39:36 2016 +0000

description:
Don't leak memory in *_alloc_*td_chain if allocation fails.

diffstat:

 sys/dev/usb/ehci.c |  5 +++--
 sys/dev/usb/ohci.c |  5 +++--
 sys/dev/usb/uhci.c |  6 ++++--
 3 files changed, 10 insertions(+), 6 deletions(-)

diffs (79 lines):

diff -r e009574c61e9 -r e3d5d2d6294a sys/dev/usb/ehci.c
--- a/sys/dev/usb/ehci.c        Sat Apr 16 15:11:45 2016 +0000
+++ b/sys/dev/usb/ehci.c        Sat Apr 16 15:39:36 2016 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: ehci.c,v 1.234.2.98 2016/04/16 14:04:55 skrll Exp $ */
+/*     $NetBSD: ehci.c,v 1.234.2.99 2016/04/16 15:39:36 skrll Exp $ */
 
 /*
  * Copyright (c) 2004-2012 The NetBSD Foundation, Inc.
@@ -53,7 +53,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ehci.c,v 1.234.2.98 2016/04/16 14:04:55 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ehci.c,v 1.234.2.99 2016/04/16 15:39:36 skrll Exp $");
 
 #include "ohci.h"
 #include "uhci.h"
@@ -2861,6 +2861,7 @@
 
  nomem:
        ehci_free_sqtds(sc, exfer);
+       kmem_free(exfer->ex_sqtds, sizeof(ehci_soft_qtd_t *) * nsqtd);
        DPRINTF("no memory", 0, 0, 0, 0);
        return USBD_NOMEM;
 }
diff -r e009574c61e9 -r e3d5d2d6294a sys/dev/usb/ohci.c
--- a/sys/dev/usb/ohci.c        Sat Apr 16 15:11:45 2016 +0000
+++ b/sys/dev/usb/ohci.c        Sat Apr 16 15:39:36 2016 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: ohci.c,v 1.254.2.70 2016/04/04 07:43:12 skrll Exp $    */
+/*     $NetBSD: ohci.c,v 1.254.2.71 2016/04/16 15:39:36 skrll Exp $    */
 
 /*
  * Copyright (c) 1998, 2004, 2005, 2012 The NetBSD Foundation, Inc.
@@ -41,7 +41,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ohci.c,v 1.254.2.70 2016/04/04 07:43:12 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ohci.c,v 1.254.2.71 2016/04/16 15:39:36 skrll Exp $");
 
 #include "opt_usb.h"
 
@@ -554,6 +554,7 @@
 
  nomem:
        ohci_free_stds(sc, ox);
+       kmem_free(ox->ox_stds, sizeof(ohci_soft_td_t *) * nstd);
 
        return USBD_NOMEM;
 }
diff -r e009574c61e9 -r e3d5d2d6294a sys/dev/usb/uhci.c
--- a/sys/dev/usb/uhci.c        Sat Apr 16 15:11:45 2016 +0000
+++ b/sys/dev/usb/uhci.c        Sat Apr 16 15:39:36 2016 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: uhci.c,v 1.264.4.72 2016/04/11 08:02:25 skrll Exp $    */
+/*     $NetBSD: uhci.c,v 1.264.4.73 2016/04/16 15:39:36 skrll Exp $    */
 
 /*
  * Copyright (c) 1998, 2004, 2011, 2012 The NetBSD Foundation, Inc.
@@ -42,7 +42,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: uhci.c,v 1.264.4.72 2016/04/11 08:02:25 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: uhci.c,v 1.264.4.73 2016/04/16 15:39:36 skrll Exp $");
 
 #include "opt_usb.h"
 
@@ -2055,6 +2055,8 @@
                p = uhci_alloc_std(sc);
                if (p == NULL) {
                        uhci_free_stds(sc, uxfer);
+                       kmem_free(uxfer->ux_stds,
+                           sizeof(uhci_soft_td_t *) * ntd);
                        return USBD_NOMEM;
                }
                uxfer->ux_stds[i] = p;



Home | Main Index | Thread Index | Old Index