Module Name:    src
Committed By:   riastradh
Date:           Sat May 14 15:28:50 UTC 2022

Modified Files:
        src/sys/dev/usb: uvideo.c

Log Message:
uvideo(4): Avoid exposing streams with invalid descriptors.


To generate a diff of this commit:
cvs rdiff -u -r1.79 -r1.80 src/sys/dev/usb/uvideo.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/uvideo.c
diff -u src/sys/dev/usb/uvideo.c:1.79 src/sys/dev/usb/uvideo.c:1.80
--- src/sys/dev/usb/uvideo.c:1.79	Sun Apr 24 09:55:48 2022
+++ src/sys/dev/usb/uvideo.c	Sat May 14 15:28:50 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: uvideo.c,v 1.79 2022/04/24 09:55:48 hannken Exp $	*/
+/*	$NetBSD: uvideo.c,v 1.80 2022/05/14 15:28:50 riastradh Exp $	*/
 
 /*
  * Copyright (c) 2008 Patrick Mahoney
@@ -42,7 +42,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: uvideo.c,v 1.79 2022/04/24 09:55:48 hannken Exp $");
+__KERNEL_RCSID(0, "$NetBSD: uvideo.c,v 1.80 2022/05/14 15:28:50 riastradh Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_usb.h"
@@ -613,6 +613,16 @@ uvideo_attach(device_t parent, device_t 
 		aprint_error_dev(self, "couldn't establish power handler\n");
 
 	SLIST_FOREACH(vs, &sc->sc_stream_list, entries) {
+		/*
+		 * If the descriptor is invalid, there may be no
+		 * default format.
+		 *
+		 * XXX Maybe this should just be removed from the list
+		 * at some other point, but finding the right other
+		 * point is not trivial.
+		 */
+		if (vs->vs_default_format == NULL)
+			continue;
 		/* XXX initialization of vs_videodev is racy */
 		vs->vs_videodev = video_attach_mi(&uvideo_hw_if, sc->sc_dev,
 		    vs);

Reply via email to