Source-Changes-HG archive

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

[src/trunk]: src/sys/dev/usb Don't kmem_alloc(0) if there are no endpoints, o...



details:   https://anonhg.NetBSD.org/src/rev/c08f379910ce
branches:  trunk
changeset: 1003423:c08f379910ce
user:      maxv <maxv%NetBSD.org@localhost>
date:      Sun Sep 15 09:18:17 2019 +0000

description:
Don't kmem_alloc(0) if there are no endpoints, otherwise panic. Found via
vHCI.

diffstat:

 sys/dev/usb/umidi.c |  6 ++++--
 1 files changed, 4 insertions(+), 2 deletions(-)

diffs (27 lines):

diff -r 0c4931e8ea20 -r c08f379910ce sys/dev/usb/umidi.c
--- a/sys/dev/usb/umidi.c       Sun Sep 15 07:13:37 2019 +0000
+++ b/sys/dev/usb/umidi.c       Sun Sep 15 09:18:17 2019 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: umidi.c,v 1.78 2019/05/08 13:40:19 isaki Exp $ */
+/*     $NetBSD: umidi.c,v 1.79 2019/09/15 09:18:17 maxv Exp $  */
 
 /*
  * Copyright (c) 2001, 2012, 2014 The NetBSD Foundation, Inc.
@@ -32,7 +32,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: umidi.c,v 1.78 2019/05/08 13:40:19 isaki Exp $");
+__KERNEL_RCSID(0, "$NetBSD: umidi.c,v 1.79 2019/09/15 09:18:17 maxv Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_usb.h"
@@ -966,6 +966,8 @@
 
        interface_desc = usbd_get_interface_descriptor(sc->sc_iface);
        num_ep = interface_desc->bNumEndpoints;
+       if (num_ep == 0)
+               return USBD_INVAL;
        sc->sc_endpoints_len = sizeof(struct umidi_endpoint) * num_ep;
        sc->sc_endpoints = p = kmem_zalloc(sc->sc_endpoints_len, KM_SLEEP);
        sc->sc_out_num_jacks = sc->sc_in_num_jacks = 0;



Home | Main Index | Thread Index | Old Index