Module Name: src Committed By: skrll Date: Sat Apr 16 15:39:36 UTC 2016
Modified Files: src/sys/dev/usb [nick-nhusb]: ehci.c ohci.c uhci.c Log Message: Don't leak memory in *_alloc_*td_chain if allocation fails. To generate a diff of this commit: cvs rdiff -u -r1.234.2.98 -r1.234.2.99 src/sys/dev/usb/ehci.c cvs rdiff -u -r1.254.2.70 -r1.254.2.71 src/sys/dev/usb/ohci.c cvs rdiff -u -r1.264.4.72 -r1.264.4.73 src/sys/dev/usb/uhci.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/sys/dev/usb/ehci.c diff -u src/sys/dev/usb/ehci.c:1.234.2.98 src/sys/dev/usb/ehci.c:1.234.2.99 --- src/sys/dev/usb/ehci.c:1.234.2.98 Sat Apr 16 14:04:55 2016 +++ src/sys/dev/usb/ehci.c Sat Apr 16 15:39:36 2016 @@ -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 @@ ehci_alloc_sqtd_chain(ehci_softc_t *sc, 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; } Index: src/sys/dev/usb/ohci.c diff -u src/sys/dev/usb/ohci.c:1.254.2.70 src/sys/dev/usb/ohci.c:1.254.2.71 --- src/sys/dev/usb/ohci.c:1.254.2.70 Mon Apr 4 07:43:12 2016 +++ src/sys/dev/usb/ohci.c Sat Apr 16 15:39:36 2016 @@ -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 @@ ohci_alloc_std_chain(ohci_softc_t *sc, s nomem: ohci_free_stds(sc, ox); + kmem_free(ox->ox_stds, sizeof(ohci_soft_td_t *) * nstd); return USBD_NOMEM; } Index: src/sys/dev/usb/uhci.c diff -u src/sys/dev/usb/uhci.c:1.264.4.72 src/sys/dev/usb/uhci.c:1.264.4.73 --- src/sys/dev/usb/uhci.c:1.264.4.72 Mon Apr 11 08:02:25 2016 +++ src/sys/dev/usb/uhci.c Sat Apr 16 15:39:36 2016 @@ -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 @@ uhci_alloc_std_chain(uhci_softc_t *sc, s 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;