Source-Changes-HG archive

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

[src/trunk]: src/sys/dev/usb Avoid kmem_alloc(0,..), which hits an assertion.



details:   https://anonhg.NetBSD.org/src/rev/81c990a99c37
branches:  trunk
changeset: 1004308:81c990a99c37
user:      maya <maya%NetBSD.org@localhost>
date:      Wed Oct 23 00:52:39 2019 +0000

description:
Avoid kmem_alloc(0,..), which hits an assertion.

PR kern/53734: Prevent kernel panic during Wide Vision FHD Camera detection

diffstat:

 sys/dev/usb/uvideo.c |  7 +++++--
 1 files changed, 5 insertions(+), 2 deletions(-)

diffs (28 lines):

diff -r 49f8e66f4700 -r 81c990a99c37 sys/dev/usb/uvideo.c
--- a/sys/dev/usb/uvideo.c      Tue Oct 22 22:03:27 2019 +0000
+++ b/sys/dev/usb/uvideo.c      Wed Oct 23 00:52:39 2019 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: uvideo.c,v 1.49 2019/10/01 18:00:08 chs Exp $  */
+/*     $NetBSD: uvideo.c,v 1.50 2019/10/23 00:52:39 maya Exp $ */
 
 /*
  * Copyright (c) 2008 Patrick Mahoney
@@ -42,7 +42,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: uvideo.c,v 1.49 2019/10/01 18:00:08 chs Exp $");
+__KERNEL_RCSID(0, "$NetBSD: uvideo.c,v 1.50 2019/10/23 00:52:39 maya Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_usb.h"
@@ -999,6 +999,9 @@
 uvideo_unit_alloc_controls(struct uvideo_unit *vu, uint8_t size,
                           const uint8_t *controls)
 {
+       if (vu->vu_controls == 0)
+               return USBD_INVAL;
+
        vu->vu_controls = kmem_alloc(sizeof(*vu->vu_controls) * size, KM_SLEEP);
        vu->vu_control_size = size;
        memcpy(vu->vu_controls, controls, size);



Home | Main Index | Thread Index | Old Index