Source-Changes-HG archive

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

[src/trunk]: src/sys/dev/usb uvideo(4): Fix zero initialization of uvideo_str...



details:   https://anonhg.NetBSD.org/src/rev/43e4424b57cc
branches:  trunk
changeset: 362577:43e4424b57cc
user:      riastradh <riastradh%NetBSD.org@localhost>
date:      Thu Mar 03 06:22:40 2022 +0000

description:
uvideo(4): Fix zero initialization of uvideo_stream.

Just use kmem_zalloc; don't memset it to zero, especially not after
we just inserted it into the list, with the side effect of deleting
the rest of the list!

diffstat:

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

diffs (35 lines):

diff -r 952eefc8efdb -r 43e4424b57cc sys/dev/usb/uvideo.c
--- a/sys/dev/usb/uvideo.c      Thu Mar 03 06:22:23 2022 +0000
+++ b/sys/dev/usb/uvideo.c      Thu Mar 03 06:22:40 2022 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: uvideo.c,v 1.66 2022/03/03 06:22:03 riastradh Exp $    */
+/*     $NetBSD: uvideo.c,v 1.67 2022/03/03 06:22:40 riastradh Exp $    */
 
 /*
  * Copyright (c) 2008 Patrick Mahoney
@@ -42,7 +42,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: uvideo.c,v 1.66 2022/03/03 06:22:03 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: uvideo.c,v 1.67 2022/03/03 06:22:40 riastradh Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_usb.h"
@@ -752,7 +752,7 @@
 static struct uvideo_stream *
 uvideo_stream_alloc(void)
 {
-       return kmem_alloc(sizeof(struct uvideo_stream), KM_SLEEP);
+       return kmem_zalloc(sizeof(struct uvideo_stream), KM_SLEEP);
 }
 
 
@@ -1031,7 +1031,6 @@
                vs));
 
        SLIST_INSERT_HEAD(&sc->sc_stream_list, vs, entries);
-       memset(vs, 0, sizeof(*vs));
        vs->vs_parent = sc;
        vs->vs_ifaceno = ifdesc->bInterfaceNumber;
        vs->vs_subtype = 0;



Home | Main Index | Thread Index | Old Index